Skip to content

Commit

Permalink
Merge pull request pypa#1867 from benoit-pierre/drop-some-pkg_resourc…
Browse files Browse the repository at this point in the history
…es-tests-dependency-on-easy_install

test: drop pkg_resources tests dependency on easy_install
  • Loading branch information
benoit-pierre authored Nov 13, 2019
2 parents 7956986 + 14c8218 commit 5599460
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 46 deletions.
Empty file.
6 changes: 6 additions & 0 deletions pkg_resources/tests/data/my-test-package-source/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools
setuptools.setup(
name="my-test-package",
version="1.0",
zip_safe=True,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Metadata-Version: 1.0
Name: my-test-package
Version: 1.0
Summary: UNKNOWN
Home-page: UNKNOWN
Author: UNKNOWN
Author-email: UNKNOWN
License: UNKNOWN
Description: UNKNOWN
Platform: UNKNOWN
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
setup.cfg
setup.py
my_test_package.egg-info/PKG-INFO
my_test_package.egg-info/SOURCES.txt
my_test_package.egg-info/dependency_links.txt
my_test_package.egg-info/top_level.txt
my_test_package.egg-info/zip-safe
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Binary file not shown.
58 changes: 13 additions & 45 deletions pkg_resources/tests/test_find_distributions.py
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -21,46 +13,22 @@ 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 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, 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_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(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_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)
2 changes: 1 addition & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[pytest]
addopts=--doctest-modules --doctest-glob=pkg_resources/api_tests.txt -r sxX
norecursedirs=dist build *.egg setuptools/extern pkg_resources/extern tools .*
norecursedirs=dist build *.egg setuptools/extern pkg_resources/extern pkg_resources/tests/data tools .*
flake8-ignore =
setuptools/site-patch.py F821
setuptools/py*compat.py F811
Expand Down

0 comments on commit 5599460

Please sign in to comment.