Skip to content

Commit 6cbdd15

Browse files
Try isolation
1 parent b8755ba commit 6cbdd15

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

tests/test_modutils.py

+12-13
Original file line numberDiff line numberDiff line change
@@ -268,19 +268,6 @@ def test_std_lib(self) -> None:
268268
os.path.realpath(os.path.__file__.replace(".pyc", ".py")),
269269
)
270270

271-
def test_std_lib_found_before_same_named_package_on_path(self) -> None:
272-
realpath = str(resources.RESOURCE_PATH)
273-
if WIN32:
274-
# Escape backslashes.
275-
realpath = realpath.replace("\\", "\\\\")
276-
sys.path.insert(0, realpath)
277-
self.addCleanup(sys.path.pop, 0)
278-
279-
file = modutils.file_from_modpath(["copy"])
280-
281-
self.assertNotIn("test", file) # tests/testdata/python3/data/copy.py
282-
self.assertTrue(any(stdlib in file for stdlib in modutils.STD_LIB_DIRS))
283-
284271
def test_builtin(self) -> None:
285272
self.assertIsNone(modutils.file_from_modpath(["sys"]))
286273

@@ -293,6 +280,18 @@ def test_unicode_in_package_init(self) -> None:
293280
modutils.file_from_modpath(["data", "unicode_package", "core"])
294281

295282

283+
class FileFromModPathTestIsolation(unittest.TestCase):
284+
def test_std_lib_found_before_same_named_package_on_path(self) -> None:
285+
path = str(resources.RESOURCE_PATH)
286+
sys.path.insert(0, path)
287+
self.addCleanup(sys.path.pop, 0)
288+
289+
file = modutils.file_from_modpath(["copy"])
290+
291+
self.assertNotIn("test", file) # tests/testdata/python3/data/copy.py
292+
self.assertTrue(any(stdlib in file for stdlib in modutils.STD_LIB_DIRS))
293+
294+
296295
class GetSourceFileTest(unittest.TestCase):
297296
def test(self) -> None:
298297
filename = _get_file_from_object(os.path)

0 commit comments

Comments
 (0)