gh-108927: Fix test_import + test_importlib + test_unittest problem (#108929)

This commit is contained in:
Nikita Sobolev 2023-09-05 21:57:48 +03:00 committed by GitHub
parent deea7c8268
commit 3f89b25763
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View 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),