diff --git a/newsfragments/4237.misc.rst b/newsfragments/4237.misc.rst new file mode 100644 index 0000000000..995bee20e1 --- /dev/null +++ b/newsfragments/4237.misc.rst @@ -0,0 +1 @@ +Drop dependency on `py`. Bump ``pytest-xdist`` to ``>=3`` and use `pathlib` instead in tests -- by :user:`Avasam` diff --git a/pkg_resources/tests/test_find_distributions.py b/pkg_resources/tests/test_find_distributions.py index 4ffcdf3b58..8263ca6c41 100644 --- a/pkg_resources/tests/test_find_distributions.py +++ b/pkg_resources/tests/test_find_distributions.py @@ -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: @@ -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") ) diff --git a/setup.cfg b/setup.cfg index 0699bc72e7..f40fcd8265 100644 --- a/setup.cfg +++ b/setup.cfg @@ -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