FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[3.11] gh-135374: Adjust test for setuptools' replacement of distutils by encukou · Pull Request #138796 · python/cpython · GitHub

/ cpython Public
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (2) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
6 changes: 6 additions & 0 deletions Lib/test/test___all__.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ def check_all(self, modname):
self.assertEqual(keys, all_set, "in module {}".format(modname))

def walk_modules(self, basedir, modpath):
if modpath == 'distutils.':
# gh-135374: when setuptools is installed, it now replaces
# 'distutils' with its own version.
# In a security-fix only branch of CPython,
# skip the __all__ test rather than deal with the fallout.
return
for fn in sorted(os.listdir(basedir)):
path = os.path.join(basedir, fn)
if os.path.isdir(path):
Expand Down
34 changes: 27 additions & 7 deletions Lib/test/test_sundry.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from test.support import import_helper
from test.support import warnings_helper
import unittest
import sys

class TestUntestedModules(unittest.TestCase):
def test_untested_modules_can_be_imported(self):
Expand All @@ -18,6 +19,32 @@ def test_untested_modules_can_be_imported(self):
self.fail('{} has tests even though test_sundry claims '
'otherwise'.format(name))

import html.entities

try:
import tty # Not available on Windows
except ImportError:
if support.verbose:
print("skipping tty")

def test_distutils_modules(self):
with warnings_helper.check_warnings(quiet=True):

path_copy = sys.path[:]
import distutils
if '_distutils_hack' in sys.modules:
# gh-135374: when 'setuptools' is installed, it now replaces
# 'distutils' with its own version.
# This imports '_distutils_hack' and modifies sys.path.
# The setuptols version of distutils also does not include some
# of the modules tested here.

# Undo the path modifications and skip the test.

sys.path[:] = path_copy
Comment thread
zware marked this conversation as resolved.
raise unittest.SkipTest(
'setuptools has replaced distutils with its own version')

import distutils.bcppcompiler
import distutils.ccompiler
import distutils.cygwinccompiler
Expand All @@ -41,13 +68,6 @@ def test_untested_modules_can_be_imported(self):
import distutils.command.sdist
import distutils.command.upload

import html.entities

try:
import tty # Not available on Windows
except ImportError:
if support.verbose:
print("skipping tty")


if __name__ == "__main__":
Expand Down
Loading

Back | FazBrowse Home | New Git URL