]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.11] gh-108927: Fix test_import + test_importlib + test_unittest problem (GH-108929...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Wed, 4 Oct 2023 11:09:43 +0000 (04:09 -0700)
committerGitHub <noreply@github.com>
Wed, 4 Oct 2023 11:09:43 +0000 (11:09 +0000)
gh-108927: Fix test_import + test_importlib + test_unittest problem (GH-108929)
(cherry picked from commit 3f89b257639dd817a32079da2ae2c4436b8e82eb)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Lib/unittest/test/test_discovery.py

index 3b58786ec16a10af2d19a663f2c141a9a59a23b2..c39ad2e3acfb294113482b230632955b3b7b6a95 100644 (file)
@@ -6,7 +6,6 @@ import types
 import pickle
 from test import support
 from test.support import import_helper
-import test.test_importlib.util
 
 import unittest
 import unittest.mock
@@ -826,6 +825,8 @@ class TestDiscovery(unittest.TestCase):
                          'as dotted module names')
 
     def test_discovery_failed_discovery(self):
+        from test.test_importlib import util
+
         loader = unittest.TestLoader()
         package = types.ModuleType('package')
 
@@ -837,7 +838,7 @@ class TestDiscovery(unittest.TestCase):
             # Since loader.discover() can modify sys.path, restore it when done.
             with import_helper.DirsOnSysPath():
                 # Make sure to remove 'package' from sys.modules when done.
-                with test.test_importlib.util.uncache('package'):
+                with util.uncache('package'):
                     with self.assertRaises(TypeError) as cm:
                         loader.discover('package')
                     self.assertEqual(str(cm.exception),