aboutsummaryrefslogtreecommitdiff
path: root/pkg_resources/tests/test_find_distributions.py
diff options
context:
space:
mode:
Diffstat (limited to 'pkg_resources/tests/test_find_distributions.py')
-rw-r--r--pkg_resources/tests/test_find_distributions.py67
1 files changed, 22 insertions, 45 deletions
diff --git a/pkg_resources/tests/test_find_distributions.py b/pkg_resources/tests/test_find_distributions.py
index d735c59..b01b482 100644
--- a/pkg_resources/tests/test_find_distributions.py
+++ b/pkg_resources/tests/test_find_distributions.py
@@ -1,17 +1,9 @@
-import subprocess
-import sys
-
+import py
import pytest
import pkg_resources
-SETUP_TEMPLATE = """
-import setuptools
-setuptools.setup(
- name="my-test-package",
- version="1.0",
- zip_safe=True,
-)
-""".lstrip()
+
+TESTS_DATA_DIR = py.path.local(__file__).dirpath('data')
class TestFindDistributions:
@@ -21,46 +13,31 @@ class TestFindDistributions:
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 str(target_dir)
-
- @pytest.fixture
- def project_dir(self, tmpdir):
- project_dir = tmpdir.mkdir('my-test-package')
- (project_dir / "setup.py").write(SETUP_TEMPLATE)
- return str(project_dir)
+ return target_dir
def test_non_egg_dir_named_egg(self, target_dir):
- dists = pkg_resources.find_distributions(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_standalone_egg_directory(self, project_dir, target_dir):
- # install this distro as an unpacked egg:
- args = [
- sys.executable,
- '-c', 'from setuptools.command.easy_install import main; main()',
- '-mNx',
- '-d', target_dir,
- '--always-unzip',
- project_dir,
- ]
- subprocess.check_call(args)
- dists = pkg_resources.find_distributions(target_dir)
+ 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(target_dir, only=True)
+ dists = pkg_resources.find_distributions(str(target_dir), only=True)
assert not list(dists)
- def test_zipped_egg(self, project_dir, target_dir):
- # install this distro as an unpacked egg:
- args = [
- sys.executable,
- '-c', 'from setuptools.command.easy_install import main; main()',
- '-mNx',
- '-d', target_dir,
- '--zip-ok',
- project_dir,
- ]
- subprocess.check_call(args)
- dists = pkg_resources.find_distributions(target_dir)
+ 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(target_dir, only=True)
+ dists = pkg_resources.find_distributions(
+ str(target_dir / "my-test-package.zip"), only=True)
assert not list(dists)