This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: test___all__ and test_distutils alters the enviroinment: pkg_resources.PEP440Warning
Type: Stage: resolved
Components: Distutils, Tests Versions: Python 3.9, Python 3.8, Python 3.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: dstufft, eric.araujo, miss-islington, vstinner
Priority: normal Keywords: patch

Created on 2020-03-24 16:51 by vstinner, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 19139 closed vstinner, 2020-03-24 16:55
PR 20095 merged vstinner, 2020-05-14 23:22
PR 20109 merged miss-islington, 2020-05-15 16:06
PR 20110 merged miss-islington, 2020-05-15 16:06
Messages (5)
msg364941 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-03-24 16:51
Even when no test is run, test_distutils alters the environment:

$ ./python -m test -v --fail-env-changed test_distutils -m DONTEXISTS
== CPython 3.7.7+ (heads/3.7:1cdc61c767, Mar 24 2020, 17:25:30) [GCC 9.2.1 20190827 (Red Hat 9.2.1-1)]
== Linux-5.5.9-200.fc31.x86_64-x86_64-with-fedora-31-Thirty_One little-endian
== cwd: /home/vstinner/python/3.7/build/test_python_157151
== CPU count: 8
== encodings: locale=UTF-8, FS=utf-8
0:00:00 load avg: 0.37 Run tests sequentially
0:00:00 load avg: 0.37 [1/1] test_distutils

----------------------------------------------------------------------

Ran 0 tests in 0.001s

OK
Warning -- warnings.filters was modified by test_distutils
  Before: (140048876788832, [], [])
  After:  (140048876788832, [], [('ignore', None, <class 'pkg_resources.PEP440Warning'>, None, 0)]) 
test_distutils run no tests

== Tests result: NO TEST RUN ==

1 test run no tests:
    test_distutils

Total duration: 655 ms
Tests result: NO TEST RUN


The problem comes from Lib/distutils/tests/test_check.py: "from distutils.command.check import check, HAS_DOCUTILS" imports indirectly the docutils module which imports pkg_resources.

pkg_resources changes warnings filters.


docutils is installed by python3-docutils-0.15.2-1.fc31.noarch package and pkg_resources comes from python3-setuptools-41.6.0-1.fc31.noarch package.


Attached PR disables docutils to avoid side effects of "import docutils" like pkg_resources modifying warnings filters.
msg364942 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-03-24 16:52
> pkg_resources comes from python3-setuptools-41.6.0-1.fc31.noarch package.

Here is the line which alters warnings filters:

$ grep warnings /usr/lib/python3.7/site-packages/pkg_resources/__init__.py
(...)
warnings.filterwarnings("ignore", category=PEP440Warning, append=True)
msg368954 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-05-15 16:06
New changeset 6e57237faf0da8904e0130a11350cae3c5062b82 by Victor Stinner in branch 'master':
bpo-40055: test_distutils leaves warnings filters unchanged (GH-20095)
https://github.com/python/cpython/commit/6e57237faf0da8904e0130a11350cae3c5062b82
msg368955 - (view) Author: miss-islington (miss-islington) Date: 2020-05-15 16:23
New changeset 7ef275160953f00b4303149df6d919c0afe763cb by Miss Islington (bot) in branch '3.7':
bpo-40055: test_distutils leaves warnings filters unchanged (GH-20095)
https://github.com/python/cpython/commit/7ef275160953f00b4303149df6d919c0afe763cb
msg368956 - (view) Author: miss-islington (miss-islington) Date: 2020-05-15 16:25
New changeset 4e6545b002dd4d068b2538ffca60830d0e7fd369 by Miss Islington (bot) in branch '3.8':
bpo-40055: test_distutils leaves warnings filters unchanged (GH-20095)
https://github.com/python/cpython/commit/4e6545b002dd4d068b2538ffca60830d0e7fd369
History
Date User Action Args
2022-04-11 14:59:28adminsetgithub: 84236
2020-05-16 09:39:36vstinnersetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2020-05-15 16:25:08miss-islingtonsetmessages: + msg368956
2020-05-15 16:23:01miss-islingtonsetmessages: + msg368955
2020-05-15 16:06:51miss-islingtonsetpull_requests: + pull_request19417
2020-05-15 16:06:40miss-islingtonsetnosy: + miss-islington
pull_requests: + pull_request19416
2020-05-15 16:06:27vstinnersetmessages: + msg368954
2020-05-14 23:22:12vstinnersetpull_requests: + pull_request19401
2020-03-24 16:55:44vstinnersetkeywords: + patch
stage: patch review
pull_requests: + pull_request18500
2020-03-24 16:52:18vstinnersetmessages: + msg364942
2020-03-24 16:51:30vstinnercreate