summaryrefslogtreecommitdiff
path: root/pkg_resources/tests/test_find_distributions.py
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2021-11-10 12:12:49 -0500
committerJason R. Coombs <jaraco@jaraco.com>2021-11-10 12:13:40 -0500
commit958ce2304e153b274e2ff7b40b1e7d5ddd214904 (patch)
treebb1b77cfc08c31fb69eebdb0c66f5c0dde3f5223 /pkg_resources/tests/test_find_distributions.py
parent23f63dd44c5d9f75de195833d25a5f2872220c2b (diff)
parent8af23a41194ae747faf3e60f9cc19141b5e7ad24 (diff)
downloadpython-setuptools-git-958ce2304e153b274e2ff7b40b1e7d5ddd214904.tar.gz
Merge pull request #2866 into main.
Diffstat (limited to 'pkg_resources/tests/test_find_distributions.py')
-rw-r--r--pkg_resources/tests/test_find_distributions.py43
1 files changed, 43 insertions, 0 deletions
diff --git a/pkg_resources/tests/test_find_distributions.py b/pkg_resources/tests/test_find_distributions.py
new file mode 100644
index 00000000..b01b4827
--- /dev/null
+++ b/pkg_resources/tests/test_find_distributions.py
@@ -0,0 +1,43 @@
+import py
+import pytest
+import pkg_resources
+
+
+TESTS_DATA_DIR = py.path.local(__file__).dirpath('data')
+
+
+class TestFindDistributions:
+
+ @pytest.fixture
+ def target_dir(self, tmpdir):
+ target_dir = tmpdir.mkdir('target')
+ # place a .egg named directory in the target that is not an egg:
+ target_dir.mkdir('not.an.egg')
+ return target_dir
+
+ def test_non_egg_dir_named_egg(self, target_dir):
+ dists = pkg_resources.find_distributions(str(target_dir))
+ assert not list(dists)
+
+ def test_standalone_egg_directory(self, target_dir):
+ (TESTS_DATA_DIR / 'my-test-package_unpacked-egg').copy(target_dir)
+ dists = pkg_resources.find_distributions(str(target_dir))
+ assert [dist.project_name for dist in dists] == ['my-test-package']
+ dists = pkg_resources.find_distributions(str(target_dir), only=True)
+ assert not list(dists)
+
+ def test_zipped_egg(self, target_dir):
+ (TESTS_DATA_DIR / 'my-test-package_zipped-egg').copy(target_dir)
+ dists = pkg_resources.find_distributions(str(target_dir))
+ assert [dist.project_name for dist in dists] == ['my-test-package']
+ dists = pkg_resources.find_distributions(str(target_dir), only=True)
+ assert not list(dists)
+
+ def test_zipped_sdist_one_level_removed(self, target_dir):
+ (TESTS_DATA_DIR / 'my-test-package-zip').copy(target_dir)
+ dists = pkg_resources.find_distributions(
+ str(target_dir / "my-test-package.zip"))
+ assert [dist.project_name for dist in dists] == ['my-test-package']
+ dists = pkg_resources.find_distributions(
+ str(target_dir / "my-test-package.zip"), only=True)
+ assert not list(dists)