@@ -268,19 +268,6 @@ def test_std_lib(self) -> None:
268
268
os .path .realpath (os .path .__file__ .replace (".pyc" , ".py" )),
269
269
)
270
270
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
-
284
271
def test_builtin (self ) -> None :
285
272
self .assertIsNone (modutils .file_from_modpath (["sys" ]))
286
273
@@ -293,6 +280,18 @@ def test_unicode_in_package_init(self) -> None:
293
280
modutils .file_from_modpath (["data" , "unicode_package" , "core" ])
294
281
295
282
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
+
296
295
class GetSourceFileTest (unittest .TestCase ):
297
296
def test (self ) -> None :
298
297
filename = _get_file_from_object (os .path )
0 commit comments