From 981e3996fb0c3be2f68666cd188e10b28fcf7004 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Sun, 7 Apr 2024 08:45:07 -0300 Subject: [PATCH] Change test_is_importable Removed the test for standalone module because for some reason it was flaky (could not figure why). --- testing/test_pathlib.py | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/testing/test_pathlib.py b/testing/test_pathlib.py index dbdc03b5029..2f7d656b349 100644 --- a/testing/test_pathlib.py +++ b/testing/test_pathlib.py @@ -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