Skip to content

Commit 460043b

Browse files
[3.12] gh-108927: Fix test_import + test_importlib + test_unittest problem (GH-108929) (#108954)
gh-108927: Fix test_import + test_importlib + test_unittest problem (GH-108929) (cherry picked from commit 3f89b25) Co-authored-by: Nikita Sobolev <[email protected]>
1 parent 3d0827e commit 460043b

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Lib/test/test_unittest/test_discovery.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import pickle
77
from test import support
88
from test.support import import_helper
9-
import test.test_importlib.util
109

1110
import unittest
1211
import unittest.mock
@@ -826,6 +825,8 @@ def restore():
826825
'as dotted module names')
827826

828827
def test_discovery_failed_discovery(self):
828+
from test.test_importlib import util
829+
829830
loader = unittest.TestLoader()
830831
package = types.ModuleType('package')
831832

@@ -837,7 +838,7 @@ def _import(packagename, *args, **kwargs):
837838
# Since loader.discover() can modify sys.path, restore it when done.
838839
with import_helper.DirsOnSysPath():
839840
# Make sure to remove 'package' from sys.modules when done.
840-
with test.test_importlib.util.uncache('package'):
841+
with util.uncache('package'):
841842
with self.assertRaises(TypeError) as cm:
842843
loader.discover('package')
843844
self.assertEqual(str(cm.exception),

0 commit comments

Comments
 (0)