Skip to content

Commit

Permalink
Try isolation
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobtylerwalls committed Jun 26, 2023
1 parent b8755ba commit 6cbdd15
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions tests/test_modutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,19 +268,6 @@ def test_std_lib(self) -> None:
os.path.realpath(os.path.__file__.replace(".pyc", ".py")),
)

def test_std_lib_found_before_same_named_package_on_path(self) -> None:
realpath = str(resources.RESOURCE_PATH)
if WIN32:
# Escape backslashes.
realpath = realpath.replace("\\", "\\\\")
sys.path.insert(0, realpath)
self.addCleanup(sys.path.pop, 0)

file = modutils.file_from_modpath(["copy"])

self.assertNotIn("test", file) # tests/testdata/python3/data/copy.py
self.assertTrue(any(stdlib in file for stdlib in modutils.STD_LIB_DIRS))

def test_builtin(self) -> None:
self.assertIsNone(modutils.file_from_modpath(["sys"]))

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


class FileFromModPathTestIsolation(unittest.TestCase):
def test_std_lib_found_before_same_named_package_on_path(self) -> None:
path = str(resources.RESOURCE_PATH)
sys.path.insert(0, path)
self.addCleanup(sys.path.pop, 0)

file = modutils.file_from_modpath(["copy"])

self.assertNotIn("test", file) # tests/testdata/python3/data/copy.py
self.assertTrue(any(stdlib in file for stdlib in modutils.STD_LIB_DIRS))


class GetSourceFileTest(unittest.TestCase):
def test(self) -> None:
filename = _get_file_from_object(os.path)
Expand Down

0 comments on commit 6cbdd15

Please sign in to comment.