Skip to content

Commit

Permalink
Change test_is_importable
Browse files Browse the repository at this point in the history
Removed the test for standalone module because for some reason it was flaky (could not figure why).
  • Loading branch information
nicoddemus committed Apr 7, 2024
1 parent 3489fa3 commit aefa523
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions testing/test_pathlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -1376,29 +1376,26 @@ def test_full_ns_packages_without_init_files(
def test_is_importable(pytester: Pytester) -> None:
pytester.syspathinsert()

# Module package.
path = pytester.path / "is_importable/foo.py"
path = pytester.path / "bar/foo.py"
path.parent.mkdir()
path.touch()
assert is_importable("is_importable.foo", path) is True

# Standalone module.
path = pytester.path / "is_importable_module.py"
path.touch()
assert is_importable("is_importable_module", path) is True
assert is_importable("bar.foo", path) is True

# Ensure that the module that can be imported points to the path we expect.
path = pytester.path / "some/other/path/is_importable_module.py"
assert is_importable("is_importable_module", path) is False
path = pytester.path / "some/other/path/bar/foo.py"
path.mkdir(parents=True, exist_ok=True)
assert is_importable("bar.foo", path) is False

# Paths containing "." cannot be imported.
path = pytester.path / "bar.x"
path.mkdir()
path = pytester.path / "bar.x/__init__.py"
path.parent.mkdir()
path.touch()
assert is_importable("bar.x", path) is False

# Pass starting with "." denote relative imports and cannot be checked using is_importable.
path = pytester.path / ".bar.x"
path.mkdir()
path = pytester.path / ".bar.x/__init__.py"
path.parent.mkdir()
path.touch()
assert is_importable(".bar.x", path) is False


Expand Down

0 comments on commit aefa523

Please sign in to comment.