jaraco / keyring

MIT License
1.26k stars 160 forks source link

Failure in test_packaging in kloczek's environment #552

Closed jaraco closed 2 years ago

jaraco commented 2 years ago

I see at least two classes of error. The first is a single failure in test_packaging:

_____________________________________________________________________________ test_entry_point _____________________________________________________________________________

    def test_entry_point():
        """
        Keyring provides exactly one 'keyring' console script
        that's a callable.
        """
        matches = metadata.entry_points(group='console_scripts', name='keyring')
>       (script,) = matches
E       ValueError: too many values to unpack (expected 1)

tests/test_packaging.py:12: ValueError

In this case, the failure is likely due to how the tests are being run... and maybe a bug in importlib_metadata. Can you confirm what version of importlib_metadata is installed? If it's 3.5 or later (as required), I'd expect importlib_metadata to de-dupe entry points. Can you run the following to determine more about those EPs?:

python -c "import importlib_metadata as md; eps = list(md.entry_points(group='console_scripts', name='keyring')); print(eps); print([ep.dist._path for ep in eps])"

I'd expect to see something like:

[EntryPoint(name='keyring', value='keyring.cli:main', group='console_scripts')]
[PosixPath('keyring.egg-info')]

Originally posted by @jaraco in https://github.com/jaraco/keyring/issues/550#issuecomment-981129864

jaraco commented 2 years ago

@kloczek As mentioned in #550, can you please run that Python command in your environment to help elucidate why the entry points don't work in your environment?

kloczek commented 2 years ago

One sec ..

kloczek commented 2 years ago
[tkloczko@ss-desktop SPECS]$ python3 -c "import importlib_metadata as md; eps = list(md.entry_points(group='console_scripts', name='keyring')); print(eps); print([ep.dist._path for ep in eps])"
[EntryPoint(name='keyring', value='keyring.cli:main', group='console_scripts')]
[PosixPath('/usr/lib/python3.8/site-packages/keyring-23.3.0-py3.8.egg-info')]
jaraco commented 2 years ago

Well, that's weird. In the pytest context, you're getting two EntryPoint objects, but when you executed the command directly, you only got one. I don't yet understand why that is. Perhaps you could run pytest --pdb and when the test fails, execute the command import importlib_metadata as md; eps = list(md.entry_points(group='console_scripts', name='keyring')); print(eps); print([ep.dist._path for ep in eps]) and see what it returns.

jaraco commented 2 years ago

My guess is you have two copies of keyring lying around and importlib_metadata is picking up both.

kloczek commented 2 years ago

I have installes all software only out of rpm packages.

jaraco commented 2 years ago

Also, importlib_metadata 3.5+ fixes an issue where duplicate entry points are discovered for the same package, so upgrading to importlib_metadata 3.5 or later will likely also address the issue.

I don't think there's anything more keyring can do here.

jaraco commented 2 years ago

There was a recent fix in importlib_metadata that could have affected use cases like this one.

kloczek commented 2 years ago

[tkloczko@devel-g2v SPECS]$ pip show importlib_metadata
Name: importlib-metadata
Version: 4.11.3
Summary: Read metadata from Python packages
Home-page: https://github.com/python/importlib_metadata
Author: Jason R. Coombs
Author-email: jaraco@jaraco.com
License: UNKNOWN
Location: /usr/lib/python3.8/site-packages
Requires: zipp
Required-by: keyring, Sphinx

and with that version result is negative

```console + PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-keyring-23.5.0-4.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-keyring-23.5.0-4.fc35.x86_64/usr/lib/python3.8/site-packages + /usr/bin/pytest -ra =========================================================================== test session starts ============================================================================ platform linux -- Python 3.8.13, pytest-7.1.2, pluggy-1.0.0 rootdir: /home/tkloczko/rpmbuild/BUILD/keyring-23.5.0, configfile: pytest.ini plugins: cov-3.0.0, flake8-1.1.1 collected 90 items keyring/core.py . [ 1%] keyring/credentials.py . [ 2%] keyring/backends/chainer.py . [ 3%] keyring/backends/fail.py . [ 4%] keyring/backends/null.py . [ 5%] keyring/util/__init__.py . [ 6%] keyring/util/properties.py .. [ 8%] tests/test_core.py . [ 10%] tests/test_errors.py . [ 11%] tests/test_integration.py ... [ 14%] tests/test_multiprocess.py xx [ 16%] tests/test_packaging.py F. [ 18%] tests/backends/test_SecretService.py ............ [ 32%] tests/backends/test_Windows.py ssssssssssssss [ 47%] tests/backends/test_chainer.py .. [ 50%] tests/backends/test_kwallet.py ssssssssssssssssssssss [ 74%] tests/backends/test_libsecret.py ............ [ 87%] tests/backends/test_macOS.py sssssssssss [100%] ================================================================================= FAILURES ================================================================================= _____________________________________________________________________________ test_entry_point _____________________________________________________________________________ def test_entry_point(): """ Keyring provides exactly one 'keyring' console script that's a callable. """ matches = metadata.entry_points(group='console_scripts', name='keyring') > (script,) = matches E ValueError: too many values to unpack (expected 1) tests/test_packaging.py:12: ValueError ============================================================================= warnings summary ============================================================================= ../../../../../usr/lib/python3.8/site-packages/secretstorage/util.py:46: 1 warning tests/test_core.py: 1 warning tests/test_multiprocess.py: 1 warning tests/backends/test_SecretService.py: 9 warnings /usr/lib/python3.8/site-packages/secretstorage/util.py:46: UserWarning: Passing unwrap= to .send_and_get_reply() is deprecated and will break in a future version of Jeepney. return self._connection.send_and_get_reply(msg, unwrap=True) -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html ========================================================================= short test summary info ========================================================================== SKIPPED [1] keyring/testing/backend.py:68: Needs Windows SKIPPED [1] keyring/testing/backend.py:74: Needs Windows SKIPPED [1] keyring/testing/backend.py:80: Needs Windows SKIPPED [1] keyring/testing/backend.py:88: Needs Windows SKIPPED [1] keyring/testing/backend.py:94: Needs Windows SKIPPED [1] keyring/testing/backend.py:104: Needs Windows SKIPPED [1] keyring/testing/backend.py:107: Needs Windows SKIPPED [1] keyring/testing/backend.py:113: Needs Windows SKIPPED [1] keyring/testing/backend.py:124: Needs Windows SKIPPED [1] keyring/testing/backend.py:139: Needs Windows SKIPPED [1] keyring/testing/backend.py:161: Needs Windows SKIPPED [1] tests/backends/test_Windows.py:50: Needs Windows SKIPPED [1] tests/backends/test_Windows.py:53: Needs Windows SKIPPED [1] tests/backends/test_Windows.py:65: condition: sys.platform != "win32" SKIPPED [2] keyring/testing/backend.py:68: KWallet5 unavailable SKIPPED [2] keyring/testing/backend.py:74: KWallet5 unavailable SKIPPED [2] keyring/testing/backend.py:80: KWallet5 unavailable SKIPPED [2] keyring/testing/backend.py:88: KWallet5 unavailable SKIPPED [2] keyring/testing/backend.py:94: KWallet5 unavailable SKIPPED [2] keyring/testing/backend.py:104: KWallet5 unavailable SKIPPED [2] keyring/testing/backend.py:107: KWallet5 unavailable SKIPPED [2] keyring/testing/backend.py:113: KWallet5 unavailable SKIPPED [2] keyring/testing/backend.py:124: KWallet5 unavailable SKIPPED [2] keyring/testing/backend.py:139: KWallet5 unavailable SKIPPED [2] keyring/testing/backend.py:161: KWallet5 unavailable SKIPPED [1] keyring/testing/backend.py:68: macOS backend not viable SKIPPED [1] keyring/testing/backend.py:74: macOS backend not viable SKIPPED [1] keyring/testing/backend.py:80: macOS backend not viable SKIPPED [1] keyring/testing/backend.py:88: macOS backend not viable SKIPPED [1] keyring/testing/backend.py:94: macOS backend not viable SKIPPED [1] keyring/testing/backend.py:104: macOS backend not viable SKIPPED [1] keyring/testing/backend.py:107: macOS backend not viable SKIPPED [1] keyring/testing/backend.py:113: macOS backend not viable SKIPPED [1] keyring/testing/backend.py:124: macOS backend not viable SKIPPED [1] keyring/testing/backend.py:139: macOS backend not viable SKIPPED [1] keyring/testing/backend.py:161: macOS backend not viable XFAIL tests/test_multiprocess.py::test_multiprocess_get #410: keyring discovery fails intermittently XFAIL tests/test_multiprocess.py::test_multiprocess_get_after_native_get #410: keyring discovery fails intermittently FAILED tests/test_packaging.py::test_entry_point - ValueError: too many values to unpack (expected 1) ===================================================== 1 failed, 40 passed, 47 skipped, 2 xfailed, 12 warnings in 3.12s ===================================================== ```