summaryrefslogtreecommitdiff
path: root/pkg_resources/tests/test_find_distributions.py
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2021-11-12 19:37:53 -0500
committerJason R. Coombs <jaraco@jaraco.com>2021-11-12 19:37:53 -0500
commit26d7411464115c6170ed666e72e388d53d4b7fd2 (patch)
tree40a141e309c856e1af1df3dc2ec7699288d3d384 /pkg_resources/tests/test_find_distributions.py
parent342e02e7a4dbedf0e3a04c4d2d213b5340d56010 (diff)
parent77678abf97b4a8ee5e6e67b14cb21f543cd6bfd9 (diff)
downloadpython-setuptools-git-feature/local-schemes.tar.gz
Merge branch 'main' into feature/local-schemesfeature/local-schemes
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)