diff --git a/Lib/distutils/tests/__init__.py b/Lib/distutils/tests/__init__.py index 1b939cbd5db2bf..d42b343f4e940d 100644 --- a/Lib/distutils/tests/__init__.py +++ b/Lib/distutils/tests/__init__.py @@ -18,6 +18,12 @@ from test.support import run_unittest +# bpo-40055: Prevent docutils from being imported to avoid depending on +# docutils. Import docutils can have side effects. For example, docutils +# imports pkg_resources which changes warnings filters. +sys.modules['docutils'] = None + + here = os.path.dirname(__file__) or os.curdir diff --git a/Lib/distutils/tests/test_check.py b/Lib/distutils/tests/test_check.py index e534aca1d47637..040a4da774be59 100644 --- a/Lib/distutils/tests/test_check.py +++ b/Lib/distutils/tests/test_check.py @@ -4,6 +4,7 @@ import unittest from test.support import run_unittest +# bpo-40055: distutils.tests prevents docutils from being imported from distutils.command.check import check, HAS_DOCUTILS from distutils.tests import support from distutils.errors import DistutilsSetupError diff --git a/Lib/distutils/tests/test_register.py b/Lib/distutils/tests/test_register.py index e68b0af3ce0c3a..50beb267f9e0cc 100644 --- a/Lib/distutils/tests/test_register.py +++ b/Lib/distutils/tests/test_register.py @@ -14,10 +14,8 @@ from distutils.tests.test_config import BasePyPIRCCommandTestCase -try: - import docutils -except ImportError: - docutils = None +# bpo-40055: distutils.tests prevents docutils from being imported +from distutils.command.check import HAS_DOCUTILS PYPIRC_NOPASSWORD = """\ [distutils] @@ -204,7 +202,7 @@ def test_password_reset(self): self.assertEqual(headers['Content-length'], '290') self.assertIn(b'tarek', req.data) - @unittest.skipUnless(docutils is not None, 'needs docutils') + @unittest.skipUnless(HAS_DOCUTILS, 'needs docutils') def test_strict(self): # testing the script option # when on, the register command stops if @@ -270,7 +268,7 @@ def test_strict(self): finally: del register_module.input - @unittest.skipUnless(docutils is not None, 'needs docutils') + @unittest.skipUnless(HAS_DOCUTILS, 'needs docutils') def test_register_invalid_long_description(self): description = ':funkie:`str`' # mimic Sphinx-specific markup metadata = {'url': 'xxx', 'author': 'xxx', diff --git a/Misc/NEWS.d/next/Tests/2020-03-24-17-54-08.bpo-40055.AKINUq.rst b/Misc/NEWS.d/next/Tests/2020-03-24-17-54-08.bpo-40055.AKINUq.rst new file mode 100644 index 00000000000000..13b206a845d792 --- /dev/null +++ b/Misc/NEWS.d/next/Tests/2020-03-24-17-54-08.bpo-40055.AKINUq.rst @@ -0,0 +1,3 @@ +Distutils tests now prevent docutils from being imported since "import +docutils" can have side effects on tests. For example, it imports +pkg_resources which alters warnings filters. pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy