-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
bpo-40055: distutils tests now disable docutils import #19139
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
Conversation
Prevent docutils from being imported since "import docutils" can have side effects on tests. For example, it imports pkg_resources which alters warnings filters.
It is a bit sad to lose test coverage for a feature. |
I'm waiting for @pganssle who works on setuptools and so pkg_resources. |
I think @jaraco knows more about I'm not entirely sure I understand the problem here, but avoiding imports of I get that it means that importing |
regrtest (our test runner) requires that tests have zero side effects. Here the problem are warnings filters. If a test changes warnings filters: they must be saved and then restored.
Modifying sys.modules is fine.
I'm also fine with only fixing (save/restore?) warnings filters. |
+1 to add setup/teardown to save and restore warning filters then. |
I would also prefer to either clear the warnings filters or clear the warnings filters and eject I don't see the change to the warnings filters as terribly different from modifying My guess is that the principle behind tests not having side effects is that we want tests or test modules to be independent of one another. If some random test is manipulating filters that other tests may use, that would be a violation of that principle, but this is just I feel like the right long-term solution would be to move to a testing scenario where every test module is run as separate processes with their own namespaces rather than trying to make sure everything plays nicely with process-wide globals, but that feels like a much bigger undertaking than is warranted for this minor issue, so I say let's go with something where we clear the warnings filters and maybe eject |
I wrote PR #20095 to save/restore warnings filters, rather than preventing test_distutils to import docutils.
Each test file is run in a separated process by all Python CIs. But regrtest is quite strict: it requires that tests don't modify "globals" (see Lib/test/libregrtest/save_env.py). It's a watchdog to capture various kinds of bugs. |
Prevent docutils from being imported since "import docutils" can have
side effects on tests. For example, it imports pkg_resources which
alters warnings filters.
https://bugs.python.org/issue40055