summaryrefslogtreecommitdiff
path: root/setuptools/tests/config/test_expand.py
diff options
context:
space:
mode:
authorAnderson Bravalheri <andersonbravalheri@gmail.com>2022-02-09 15:52:37 +0000
committerAnderson Bravalheri <andersonbravalheri@gmail.com>2022-03-05 09:56:48 +0000
commite5d2bc8607988f776187bd6f805e56556437bd04 (patch)
tree71344aa21e8caf01be73381e5832c58fde6da231 /setuptools/tests/config/test_expand.py
parent82779f9ccf44e0d6cb4e52f960a9fe66e6c0dc01 (diff)
downloadpython-setuptools-git-e5d2bc8607988f776187bd6f805e56556437bd04.tar.gz
Parametrize test_expand.test_find_packages
Diffstat (limited to 'setuptools/tests/config/test_expand.py')
-rw-r--r--setuptools/tests/config/test_expand.py31
1 files changed, 16 insertions, 15 deletions
diff --git a/setuptools/tests/config/test_expand.py b/setuptools/tests/config/test_expand.py
index c33565a0..1898792b 100644
--- a/setuptools/tests/config/test_expand.py
+++ b/setuptools/tests/config/test_expand.py
@@ -85,29 +85,30 @@ def test_resolve_class():
assert expand.resolve_class("setuptools.command.sdist.sdist") == sdist
-def test_find_packages(tmp_path, monkeypatch):
+@pytest.mark.parametrize(
+ 'args, pkgs',
+ [
+ ({"where": ["."]}, {"pkg", "other"}),
+ ({"where": [".", "dir1"]}, {"pkg", "other", "dir2"}),
+ ({"namespaces": True}, {"pkg", "other", "dir1", "dir1.dir2"}),
+ ]
+)
+def test_find_packages(tmp_path, monkeypatch, args, pkgs):
files = {
"pkg/__init__.py",
"other/__init__.py",
"dir1/dir2/__init__.py",
}
-
write_files({k: "" for k in files}, tmp_path)
with monkeypatch.context() as m:
m.chdir(tmp_path)
- assert set(expand.find_packages(where=['.'])) == {"pkg", "other"}
- expected = {"pkg", "other", "dir2"}
- assert set(expand.find_packages(where=['.', "dir1"])) == expected
- expected = {"pkg", "other", "dir1", "dir1.dir2"}
- assert set(expand.find_packages(namespaces="True")) == expected
+ assert set(expand.find_packages(**args)) == pkgs
# Make sure the same APIs work outside cwd
- path = str(tmp_path).replace(os.sep, '/') # ensure posix-style paths
- dir1_path = str(tmp_path / "dir1").replace(os.sep, '/')
-
- assert set(expand.find_packages(where=[path])) == {"pkg", "other"}
- expected = {"pkg", "other", "dir2"}
- assert set(expand.find_packages(where=[path, dir1_path])) == expected
- expected = {"pkg", "other", "dir1", "dir1.dir2"}
- assert set(expand.find_packages(where=[path], namespaces="True")) == expected
+ where = [
+ str((tmp_path / p).resolve()).replace(os.sep, "/") # ensure posix-style paths
+ for p in args.pop("where", ["."])
+ ]
+
+ assert set(expand.find_packages(where=where, **args)) == pkgs