mirror of
https://github.com/python/cpython.git
synced 2025-10-24 15:36:26 +00:00
gh-108927: Fix test_import + test_importlib + test_unittest problem (#108929)
This commit is contained in:
parent
deea7c8268
commit
3f89b25763
1 changed files with 3 additions and 2 deletions
|
|
@ -6,7 +6,6 @@ import types
|
||||||
import pickle
|
import pickle
|
||||||
from test import support
|
from test import support
|
||||||
from test.support import import_helper
|
from test.support import import_helper
|
||||||
import test.test_importlib.util
|
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
import unittest.mock
|
import unittest.mock
|
||||||
|
|
@ -826,6 +825,8 @@ class TestDiscovery(unittest.TestCase):
|
||||||
'as dotted module names')
|
'as dotted module names')
|
||||||
|
|
||||||
def test_discovery_failed_discovery(self):
|
def test_discovery_failed_discovery(self):
|
||||||
|
from test.test_importlib import util
|
||||||
|
|
||||||
loader = unittest.TestLoader()
|
loader = unittest.TestLoader()
|
||||||
package = types.ModuleType('package')
|
package = types.ModuleType('package')
|
||||||
|
|
||||||
|
|
@ -837,7 +838,7 @@ class TestDiscovery(unittest.TestCase):
|
||||||
# Since loader.discover() can modify sys.path, restore it when done.
|
# Since loader.discover() can modify sys.path, restore it when done.
|
||||||
with import_helper.DirsOnSysPath():
|
with import_helper.DirsOnSysPath():
|
||||||
# Make sure to remove 'package' from sys.modules when done.
|
# 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:
|
with self.assertRaises(TypeError) as cm:
|
||||||
loader.discover('package')
|
loader.discover('package')
|
||||||
self.assertEqual(str(cm.exception),
|
self.assertEqual(str(cm.exception),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue