Skip to content
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___all__ and test_distutils alters the enviroinment: pkg_resources.PEP440Warning #84236

Closed
vstinner opened this issue Mar 24, 2020 · 5 comments
Labels
3.7 (EOL) end of life 3.8 (EOL) end of life 3.9 only security fixes stdlib Python modules in the Lib dir tests Tests in the Lib/test dir

Comments

@vstinner
Copy link
Member

BPO 40055
Nosy @vstinner, @merwok, @dstufft, @miss-islington
PRs
  • bpo-40055: distutils tests now disable docutils import #19139
  • bpo-40055: Fix warnings filters in test_distutils #20095
  • [3.8] bpo-40055: test_distutils leaves warnings filters unchanged (GH-20095) #20109
  • [3.7] bpo-40055: test_distutils leaves warnings filters unchanged (GH-20095) #20110
  • 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:

    assignee = None
    closed_at = <Date 2020-05-16.09:39:36.483>
    created_at = <Date 2020-03-24.16:51:30.783>
    labels = ['tests', '3.8', '3.7', 'library', '3.9']
    title = 'test___all__ and test_distutils alters the enviroinment: pkg_resources.PEP440Warning'
    updated_at = <Date 2020-05-16.09:39:36.483>
    user = 'https://github.com/vstinner'

    bugs.python.org fields:

    activity = <Date 2020-05-16.09:39:36.483>
    actor = 'vstinner'
    assignee = 'none'
    closed = True
    closed_date = <Date 2020-05-16.09:39:36.483>
    closer = 'vstinner'
    components = ['Distutils', 'Tests']
    creation = <Date 2020-03-24.16:51:30.783>
    creator = 'vstinner'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 40055
    keywords = ['patch']
    message_count = 5.0
    messages = ['364941', '364942', '368954', '368955', '368956']
    nosy_count = 4.0
    nosy_names = ['vstinner', 'eric.araujo', 'dstufft', 'miss-islington']
    pr_nums = ['19139', '20095', '20109', '20110']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue40055'
    versions = ['Python 3.7', 'Python 3.8', 'Python 3.9']

    @vstinner
    Copy link
    Member Author

    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.

    @vstinner vstinner added 3.7 (EOL) end of life 3.8 (EOL) end of life 3.9 only security fixes stdlib Python modules in the Lib dir tests Tests in the Lib/test dir labels Mar 24, 2020
    @vstinner
    Copy link
    Member Author

    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)

    @vstinner
    Copy link
    Member Author

    New changeset 6e57237 by Victor Stinner in branch 'master':
    bpo-40055: test_distutils leaves warnings filters unchanged (GH-20095)
    6e57237

    @miss-islington
    Copy link
    Contributor

    New changeset 7ef2751 by Miss Islington (bot) in branch '3.7':
    bpo-40055: test_distutils leaves warnings filters unchanged (GH-20095)
    7ef2751

    @miss-islington
    Copy link
    Contributor

    New changeset 4e6545b by Miss Islington (bot) in branch '3.8':
    bpo-40055: test_distutils leaves warnings filters unchanged (GH-20095)
    4e6545b

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    miss-islington pushed a commit that referenced this issue Aug 9, 2022
    …H-95837)
    
    Under certain build conditions, test_check_c_globals fails.  This fix takes the same approach as we took for gh-84236 (via gh-20095).  We'll be removing use of distutils in the c-analyzer at some point.  Until then we'll hide the warning filter.
    miss-islington pushed a commit to miss-islington/cpython that referenced this issue Aug 9, 2022
    …als (pythonGH-95837)
    
    Under certain build conditions, test_check_c_globals fails.  This fix takes the same approach as we took for pythongh-84236 (via pythongh-20095).  We'll be removing use of distutils in the c-analyzer at some point.  Until then we'll hide the warning filter.
    (cherry picked from commit 3ff6d9a)
    
    Co-authored-by: Eric Snow <[email protected]>
    ambv pushed a commit that referenced this issue Aug 10, 2022
    …H-95837) (GH-95843)
    
    Under certain build conditions, test_check_c_globals fails.  This fix takes the same approach as we took for gh-84236 (via gh-20095).  We'll be removing use of distutils in the c-analyzer at some point.  Until then we'll hide the warning filter.
    (cherry picked from commit 3ff6d9a)
    
    Co-authored-by: Eric Snow <[email protected]>
    miss-islington pushed a commit to miss-islington/cpython that referenced this issue Aug 10, 2022
    …als (pythonGH-95837)
    
    Under certain build conditions, test_check_c_globals fails.  This fix takes the same approach as we took for pythongh-84236 (via pythongh-20095).  We'll be removing use of distutils in the c-analyzer at some point.  Until then we'll hide the warning filter.
    (cherry picked from commit 3ff6d9a)
    
    Co-authored-by: Eric Snow <[email protected]>
    miss-islington added a commit that referenced this issue Aug 11, 2022
    …H-95837)
    
    Under certain build conditions, test_check_c_globals fails.  This fix takes the same approach as we took for gh-84236 (via gh-20095).  We'll be removing use of distutils in the c-analyzer at some point.  Until then we'll hide the warning filter.
    (cherry picked from commit 3ff6d9a)
    
    Co-authored-by: Eric Snow <[email protected]>
    iritkatriel pushed a commit to iritkatriel/cpython that referenced this issue Aug 11, 2022
    …als (pythonGH-95837)
    
    Under certain build conditions, test_check_c_globals fails.  This fix takes the same approach as we took for pythongh-84236 (via pythongh-20095).  We'll be removing use of distutils in the c-analyzer at some point.  Until then we'll hide the warning filter.
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.7 (EOL) end of life 3.8 (EOL) end of life 3.9 only security fixes stdlib Python modules in the Lib dir tests Tests in the Lib/test dir
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants