Change test_is_importable
Removed the test for standalone module because for some reason it was flaky (could not figure why).
This commit is contained in:
parent
451a12c451
commit
981e3996fb
|
@ -1376,29 +1376,26 @@ class TestNamespacePackages:
|
||||||
def test_is_importable(pytester: Pytester) -> None:
|
def test_is_importable(pytester: Pytester) -> None:
|
||||||
pytester.syspathinsert()
|
pytester.syspathinsert()
|
||||||
|
|
||||||
# Module package.
|
path = pytester.path / "bar/foo.py"
|
||||||
path = pytester.path / "is_importable/foo.py"
|
|
||||||
path.parent.mkdir()
|
path.parent.mkdir()
|
||||||
path.touch()
|
path.touch()
|
||||||
assert is_importable("is_importable.foo", path) is True
|
assert is_importable("bar.foo", path) is True
|
||||||
|
|
||||||
# Standalone module.
|
|
||||||
path = pytester.path / "is_importable_module.py"
|
|
||||||
path.touch()
|
|
||||||
assert is_importable("is_importable_module", path) is True
|
|
||||||
|
|
||||||
# Ensure that the module that can be imported points to the path we expect.
|
# Ensure that the module that can be imported points to the path we expect.
|
||||||
path = pytester.path / "some/other/path/is_importable_module.py"
|
path = pytester.path / "some/other/path/bar/foo.py"
|
||||||
assert is_importable("is_importable_module", path) is False
|
path.mkdir(parents=True, exist_ok=True)
|
||||||
|
assert is_importable("bar.foo", path) is False
|
||||||
|
|
||||||
# Paths containing "." cannot be imported.
|
# Paths containing "." cannot be imported.
|
||||||
path = pytester.path / "bar.x"
|
path = pytester.path / "bar.x/__init__.py"
|
||||||
path.mkdir()
|
path.parent.mkdir()
|
||||||
|
path.touch()
|
||||||
assert is_importable("bar.x", path) is False
|
assert is_importable("bar.x", path) is False
|
||||||
|
|
||||||
# Pass starting with "." denote relative imports and cannot be checked using is_importable.
|
# Pass starting with "." denote relative imports and cannot be checked using is_importable.
|
||||||
path = pytester.path / ".bar.x"
|
path = pytester.path / ".bar.x/__init__.py"
|
||||||
path.mkdir()
|
path.parent.mkdir()
|
||||||
|
path.touch()
|
||||||
assert is_importable(".bar.x", path) is False
|
assert is_importable(".bar.x", path) is False
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue