10000 bpo-40055: distutils tests now disable docutils import by vstinner · Pull Request #19139 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Lib/distutils/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
1 change: 1 addition & 0 deletions Lib/distutils/tests/test_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 4 additions & 6 deletions Lib/distutils/tests/test_register.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
0