Skip to content

Commit 14c8218

Browse files
committed
test: drop pkg_resources tests dependency on easy_install
1 parent 7956986 commit 14c8218

File tree

10 files changed

+40
-46
lines changed

10 files changed

+40
-46
lines changed

pkg_resources/tests/data/my-test-package-source/setup.cfg

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import setuptools
2+
setuptools.setup(
3+
name="my-test-package",
4+
version="1.0",
5+
zip_safe=True,
6+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Metadata-Version: 1.0
2+
Name: my-test-package
3+
Version: 1.0
4+
Summary: UNKNOWN
5+
Home-page: UNKNOWN
6+
Author: UNKNOWN
7+
Author-email: UNKNOWN
8+
License: UNKNOWN
9+
Description: UNKNOWN
10+
Platform: UNKNOWN
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
setup.cfg
2+
setup.py
3+
my_test_package.egg-info/PKG-INFO
4+
my_test_package.egg-info/SOURCES.txt
5+
my_test_package.egg-info/dependency_links.txt
6+
my_test_package.egg-info/top_level.txt
7+
my_test_package.egg-info/zip-safe
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Binary file not shown.
+13-45
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,9 @@
1-
import subprocess
2-
import sys
3-
1+
import py
42
import pytest
53
import pkg_resources
64

7-
SETUP_TEMPLATE = """
8-
import setuptools
9-
setuptools.setup(
10-
name="my-test-package",
11-
version="1.0",
12-
zip_safe=True,
13-
)
14-
""".lstrip()
5+
6+
TESTS_DATA_DIR = py.path.local(__file__).dirpath('data')
157

168

179
class TestFindDistributions:
@@ -21,46 +13,22 @@ def target_dir(self, tmpdir):
2113
target_dir = tmpdir.mkdir('target')
2214
# place a .egg named directory in the target that is not an egg:
2315
target_dir.mkdir('not.an.egg')
24-
return str(target_dir)
25-
26-
@pytest.fixture
27-
def project_dir(self, tmpdir):
28-
project_dir = tmpdir.mkdir('my-test-package')
29-
(project_dir / "setup.py").write(SETUP_TEMPLATE)
30-
return str(project_dir)
16+
return target_dir
3117

3218
def test_non_egg_dir_named_egg(self, target_dir):
33-
dists = pkg_resources.find_distributions(target_dir)
19+
dists = pkg_resources.find_distributions(str(target_dir))
3420
assert not list(dists)
3521

36-
def test_standalone_egg_directory(self, project_dir, target_dir):
37-
# install this distro as an unpacked egg:
38-
args = [
39-
sys.executable,
40-
'-c', 'from setuptools.command.easy_install import main; main()',
41-
'-mNx',
42-
'-d', target_dir,
43-
'--always-unzip',
44-
project_dir,
45-
]
46-
subprocess.check_call(args)
47-
dists = pkg_resources.find_distributions(target_dir)
22+
def test_standalone_egg_directory(self, target_dir):
23+
(TESTS_DATA_DIR / 'my-test-package_unpacked-egg').copy(target_dir)
24+
dists = pkg_resources.find_distributions(str(target_dir))
4825
assert [dist.project_name for dist in dists] == ['my-test-package']
49-
dists = pkg_resources.find_distributions(target_dir, only=True)
26+
dists = pkg_resources.find_distributions(str(target_dir), only=True)
5027
assert not list(dists)
5128

52-
def test_zipped_egg(self, project_dir, target_dir):
53-
# install this distro as an unpacked egg:
54-
args = [
55-
sys.executable,
56-
'-c', 'from setuptools.command.easy_install import main; main()',
57-
'-mNx',
58-
'-d', target_dir,
59-
'--zip-ok',
60-
project_dir,
61-
]
62-
subprocess.check_call(args)
63-
dists = pkg_resources.find_distributions(target_dir)
29+
def test_zipped_egg(self, target_dir):
30+
(TESTS_DATA_DIR / 'my-test-package_zipped-egg').copy(target_dir)
31+
dists = pkg_resources.find_distributions(str(target_dir))
6432
assert [dist.project_name for dist in dists] == ['my-test-package']
65-
dists = pkg_resources.find_distributions(target_dir, only=True)
33+
dists = pkg_resources.find_distributions(str(target_dir), only=True)
6634
assert not list(dists)

pytest.ini

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[pytest]
22
addopts=--doctest-modules --doctest-glob=pkg_resources/api_tests.txt -r sxX
3-
norecursedirs=dist build *.egg setuptools/extern pkg_resources/extern tools .*
3+
norecursedirs=dist build *.egg setuptools/extern pkg_resources/extern pkg_resources/tests/data tools .*
44
flake8-ignore =
55
setuptools/site-patch.py F821
66
setuptools/py*compat.py F811

0 commit comments

Comments
 (0)