summaryrefslogtreecommitdiff
path: root/setuptools/tests/test_editable_install.py
diff options
context:
space:
mode:
authorAnderson Bravalheri <andersonbravalheri@gmail.com>2022-08-12 12:32:05 +0100
committerAnderson Bravalheri <andersonbravalheri@gmail.com>2022-08-12 12:32:05 +0100
commit8a5d6cc71bf1c4c1c2c153683fb43d51ce596167 (patch)
treeea4711587a0e99f2e854eb91af58a60a3d877266 /setuptools/tests/test_editable_install.py
parenta4d181bfc628c0fa6fac61218575017c91f9c2f0 (diff)
downloadpython-setuptools-git-8a5d6cc71bf1c4c1c2c153683fb43d51ce596167.tar.gz
Replicate error in issue 3504
Diffstat (limited to 'setuptools/tests/test_editable_install.py')
-rw-r--r--setuptools/tests/test_editable_install.py48
1 files changed, 48 insertions, 0 deletions
diff --git a/setuptools/tests/test_editable_install.py b/setuptools/tests/test_editable_install.py
index ea31cb46..e23431f5 100644
--- a/setuptools/tests/test_editable_install.py
+++ b/setuptools/tests/test_editable_install.py
@@ -269,6 +269,54 @@ class TestPep420Namespaces:
venv.run(["python", "-m", "pip", "install", "-e", str(pkg_C), *opts])
venv.run(["python", "-c", "from myns.n import pkgA, pkgB, pkgC"])
+ def test_namespace_accidental_config_in_lenient_mode(self, venv, tmp_path):
+ """Sometimes users might specify an ``include`` pattern that ignores parent
+ packages. In a normal installation this would ignore all modules inside the
+ parent packages, and make them namespaces (reported in issue #3504),
+ so the editable mode should preserve this behaviour.
+ """
+ files = {
+ "pkgA": {
+ "pyproject.toml": dedent("""\
+ [build-system]
+ requires = ["setuptools", "wheel"]
+ build-backend = "setuptools.build_meta"
+
+ [project]
+ name = "pkgA"
+ version = "3.14159"
+
+ [tool.setuptools]
+ packages.find.include = ["mypkg.*"]
+ """),
+ "mypkg": {
+ "__init__.py": "",
+ "other.py": "b = 1",
+ "n": {
+ "__init__.py": "",
+ "pkgA.py": "a = 1",
+ },
+ },
+ "MANIFEST.in": EXAMPLE["MANIFEST.in"],
+ },
+ }
+ jaraco.path.build(files, prefix=tmp_path)
+ pkg_A = tmp_path / "pkgA"
+
+ # use pip to install to the target directory
+ opts = ["--no-build-isolation"] # force current version of setuptools
+ venv.run(["python", "-m", "pip", "-v", "install", "-e", str(pkg_A), *opts])
+ out = venv.run(["python", "-c", "from mypkg.n import pkgA; print(pkgA.a)"])
+ assert str(out, "utf-8").strip() == "1"
+ cmd = """\
+ try:
+ import mypkg.other
+ except ImportError:
+ print("mypkg.other not defined")
+ """
+ out = venv.run(["python", "-c", dedent(cmd)])
+ assert "mypkg.other not defined" in str(out, "utf-8")
+
# Moved here from test_develop:
@pytest.mark.xfail(