-
-
Notifications
You must be signed in to change notification settings - Fork 31.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test_entry_points_by_index (test.test_importlib.test_metadata_api.APITests) fails on Fedora 33 and 34 #88617
Comments
Hello. When we attempted to upgrade to Python 3.10.0b3 on Fedora 33 and 34, we see the following test failure: ====================================================================== Traceback (most recent call last):
File "/builddir/build/BUILD/Python-3.10.0b3/Lib/test/test_importlib/test_metadata_api.py", line 145, in test_entry_points_by_index
expected = next(iter(caught))
StopIteration Ran 1402 tests in 2.125s I've reproduced it without any Fedora's patches: $ cd cpython
$ git switch -d v3.10.0b3 # or the tip of 3.10 today, 77eaf14d27
$ ./configure --enable-shared && make $ LD_LIBRARY_PATH=. ./python -m test test_importlib
0:00:00 load avg: 13.59 Run tests sequentially
0:00:00 load avg: 13.59 [1/1] test_importlib
test test_importlib failed -- Traceback (most recent call last):
File "/home/churchyard/Dokumenty/RedHat/cpython/Lib/test/test_importlib/test_metadata_api.py", line 145, in test_entry_points_by_index
expected = next(iter(caught))
StopIteration test_importlib failed == Tests result: FAILURE == 1 test failed: Total duration: 11.0 sec |
Also reproduced on the main branch. |
This seems to have been reported also at https://bugs.python.org/issue44246#msg395202 |
Also reproducible without --enable-shared. [cpython (main)]$ ./configure && make [cpython (main)]$ ./python -m test test_importlib
0:00:00 load avg: 5.40 Run tests sequentially
0:00:00 load avg: 5.40 [1/1] test_importlib
test test_importlib failed -- Traceback (most recent call last):
File "/home/churchyard/Dokumenty/RedHat/cpython/Lib/test/test_importlib/test_metadata_api.py", line 145, in test_entry_points_by_index
expected = next(iter(caught))
StopIteration test_importlib failed == Tests result: FAILURE == 1 test failed: Total duration: 3.5 sec |
I get the DeprecationWarning the tests assumes when not running via the test: $ cat distinfo_pkg-1.0.0.dist-info/entry_points.txt
[entries]
main = mod:main
ns:sub = mod:main $ ./python
Python 3.11.0a0 (heads/main:0982ded179, Jun 18 2021, 14:14:16) [GCC 10.3.1 20210422 (Red Hat 10.3.1-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import os, sys
>>> sys.path.insert(0, os.path.abspath('.'))
>>> from importlib.metadata import distribution
>>> distribution('distinfo-pkg')
<importlib.metadata.PathDistribution object at 0x7f1796d8bcd0>
>>> eps = distribution('distinfo-pkg').entry_points
>>> eps[0]
<stdin>:1: DeprecationWarning: Accessing entry points by index is deprecated. Cast to tuple if needed.
EntryPoint(name='main', value='mod:main', group='entries') Not sure why I don't get it in the test yet. |
I've added warnings.resetwarnings() to the test. it makes it pass. It says: Warning -- warnings.filters was modified by test_importlib |
Adding the reset to the context manager: with warnings.catch_warnings(record=True) as caught:
warnings.resetwarnings()
eps[0] Or even better explicitly: with warnings.catch_warnings(record=True) as caught:
warnings.filterwarnings("default", category=DeprecationWarning)
eps[0] Makes it pass and makes the tests framework happy. I still don't understand why it is filtered, but other tests in the file (e.g. test_entry_points_dict_construction) already o this, so I will submit a pull request. |
Other tests reset the filters? Good observation. I’d missed that detail. If it’s easier to submit a PR to importlib_metadata, feel free to do that as I’ll want the change in both places. |
Submitted to both. |
Big thanks Miro for the detailed work on this matter. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: