Skip to content

Commit

Permalink
Merge pull request #4237 from Avasam/change-py-for-pathlib
Browse files Browse the repository at this point in the history
Use `pathlib` instead of `py`
  • Loading branch information
jaraco authored Mar 3, 2024
2 parents ecfd1ce + c6ebe3d commit 2d5c7d5
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
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 @@ -60,7 +60,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

0 comments on commit 2d5c7d5

Please sign in to comment.