Skip to content

test___all__ and test_distutils alters the enviroinment: pkg_resources.PEP440Warning #84236

Description

@vstinner
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']

    Activity

    1. vstinner commented on Mar 24, 2020

      @vstinner
      MemberAuthor

      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.

    2. added
      stdlibStandard Library Python modules in the Lib/ directory
      testsTests in the Lib/test dir
      on Mar 24, 2020
    3. vstinner commented on Mar 24, 2020

      @vstinner
      MemberAuthor

      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)
    4. vstinner commented on May 15, 2020

      @vstinner
      MemberAuthor

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

    5. miss-islington commented on May 15, 2020

      @miss-islington
      Contributor

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

    6. miss-islington commented on May 15, 2020

      @miss-islington
      Contributor

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

    7. transferred this issue fromon Apr 10, 2022
    8. added 2 commits that reference this issue on Aug 9, 2022
    9. added a commit that references this issue on Aug 10, 2022
    10. added 2 commits that reference this issue on Aug 10, 2022
    11. added a commit that references this issue on Aug 11, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      3.7 (EOL)end of life3.8 (EOL)end of life3.9 (EOL)end of lifestdlibStandard Library Python modules in the Lib/ directorytestsTests in the Lib/test dir

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions