Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use pathlib instead of py #4237

Merged
merged 1 commit into from
Mar 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions newsfragments/4237.misc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Drop dependency on `py`. Bump ``pytest-xdist`` to ``>=3`` and use `pathlib` instead in tests -- by :user:`Avasam`
21 changes: 16 additions & 5 deletions pkg_resources/tests/test_find_distributions.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import py
from pathlib import Path
import shutil
import pytest
import pkg_resources


TESTS_DATA_DIR = py.path.local(__file__).dirpath('data')
TESTS_DATA_DIR = Path(__file__).parent / 'data'


class TestFindDistributions:
Expand All @@ -19,21 +20,31 @@ def test_non_egg_dir_named_egg(self, 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)
shutil.copytree(
TESTS_DATA_DIR / 'my-test-package_unpacked-egg',
target_dir,
dirs_exist_ok=True,
)
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)
shutil.copytree(
TESTS_DATA_DIR / 'my-test-package_zipped-egg',
target_dir,
dirs_exist_ok=True,
)
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)
shutil.copytree(
TESTS_DATA_DIR / 'my-test-package-zip', target_dir, dirs_exist_ok=True
)
dists = pkg_resources.find_distributions(
str(target_dir / "my-test-package.zip")
)
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ testing =
pip>=19.1 # For proper file:// URLs support.
packaging>=23.2
jaraco.envs>=2.2
pytest-xdist
pytest-xdist>=3 # Dropped dependency on pytest-fork and py
jaraco.path>=3.2.0
build[virtualenv]
filelock>=3.4.0
Expand Down
Loading