Skip to content

Commit

Permalink
[3.11] gh-108927: Fix test_import + test_importlib + test_unittest pr…
Browse files Browse the repository at this point in the history
…oblem (GH-108929) (#110347)

gh-108927: Fix test_import + test_importlib + test_unittest problem (GH-108929)
(cherry picked from commit 3f89b25)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
  • Loading branch information
miss-islington and sobolevn committed Oct 4, 2023
1 parent f9ac377 commit 497c8c4
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Lib/unittest/test/test_discovery.py
Expand Up @@ -6,7 +6,6 @@
import pickle
from test import support
from test.support import import_helper
import test.test_importlib.util

import unittest
import unittest.mock
Expand Down Expand Up @@ -826,6 +825,8 @@ def restore():
'as dotted module names')

def test_discovery_failed_discovery(self):
from test.test_importlib import util

loader = unittest.TestLoader()
package = types.ModuleType('package')

Expand All @@ -837,7 +838,7 @@ def _import(packagename, *args, **kwargs):
# 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),
Expand Down

0 comments on commit 497c8c4

Please sign in to comment.