summaryrefslogtreecommitdiff
path: root/setuptools/tests/test_editable_install.py
diff options
context:
space:
mode:
authorAnderson Bravalheri <andersonbravalheri@gmail.com>2022-04-12 01:07:07 +0100
committerAnderson Bravalheri <andersonbravalheri@gmail.com>2022-06-15 16:43:52 +0100
commit55260a7f60750b154b9024cd1961dfddfb6f3866 (patch)
tree45a94507bfd883e1419f8039f51d1b2a635d41ca /setuptools/tests/test_editable_install.py
parent01ceef68343a42a3bb6592111305fac694a16acf (diff)
downloadpython-setuptools-git-55260a7f60750b154b9024cd1961dfddfb6f3866.tar.gz
Prevent errors when __path__ is not set
Diffstat (limited to 'setuptools/tests/test_editable_install.py')
-rw-r--r--setuptools/tests/test_editable_install.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/setuptools/tests/test_editable_install.py b/setuptools/tests/test_editable_install.py
index 43a4f726..fc3d6217 100644
--- a/setuptools/tests/test_editable_install.py
+++ b/setuptools/tests/test_editable_install.py
@@ -296,7 +296,7 @@ class TestFinderTemplate:
assert mod1.a == 42
assert mod2.a == 43
expected = str((tmp_path / "src1/pkg1/subpkg").resolve())
- assert str(Path(subpkg.__path__[0]).resolve()) == expected
+ self.assert_path(subpkg, expected)
def test_namespace(self, tmp_path):
files = {"pkg": {"__init__.py": "a = 13", "text.txt": "abc"}}
@@ -312,7 +312,7 @@ class TestFinderTemplate:
text = importlib_resources.files(pkg) / "text.txt"
expected = str((tmp_path / "pkg").resolve())
- assert str(Path(pkg.__path__[0]).resolve()) == expected
+ self.assert_path(pkg, expected)
assert pkg.a == 13
# Make sure resources can also be found
@@ -337,10 +337,16 @@ class TestFinderTemplate:
mod2 = import_module("ns.mod2")
expected = str((tmp_path / "src1/ns/pkg1").resolve())
- assert str(Path(pkgA.__path__[0]).resolve()) == expected
+ self.assert_path(pkgA, expected)
assert pkgA.a == 13
assert mod2.b == 37
+ def assert_path(self, pkg, expected):
+ if pkg.__path__:
+ path = next(iter(pkg.__path__), None)
+ if path:
+ assert str(Path(path).resolve()) == expected
+
def test_pkg_roots(tmp_path):
"""This test focus in getting a particular implementation detail right.