From 18042fb803ff71a813b595769588bfdf7cac103c Mon Sep 17 00:00:00 2001 From: Avasam Date: Fri, 16 Aug 2024 14:14:33 -0400 Subject: [PATCH] Ignore deprecated PT004 and PT005 --- pkg_resources/tests/test_resources.py | 2 +- ruff.toml | 6 ++++-- setuptools/tests/fixtures.py | 4 ++-- setuptools/tests/integration/test_pip_install_sdist.py | 2 +- setuptools/tests/test_bdist_egg.py | 4 ++-- setuptools/tests/test_develop.py | 2 +- setuptools/tests/test_easy_install.py | 8 ++++---- setuptools/tests/test_setuptools.py | 6 +++--- setuptools/tests/test_virtualenv.py | 2 +- 9 files changed, 19 insertions(+), 17 deletions(-) diff --git a/pkg_resources/tests/test_resources.py b/pkg_resources/tests/test_resources.py index 9f48fdcd8ff..c23a241b3f9 100644 --- a/pkg_resources/tests/test_resources.py +++ b/pkg_resources/tests/test_resources.py @@ -778,7 +778,7 @@ def symlinked_tmpdir(self, tmpdir): os.unlink(link_name) @pytest.fixture(autouse=True) - def _patched_path(self, tmpdir): + def patched_path(self, tmpdir): """ Patch sys.path to include the 'site-pkgs' dir. Also restore pkg_resources._namespace_packages to its diff --git a/ruff.toml b/ruff.toml index 61a1e2a6da6..5817c62c709 100644 --- a/ruff.toml +++ b/ruff.toml @@ -22,6 +22,8 @@ extend-select = [ "YTT", # flake8-2020 ] ignore = [ + "PT004", # deprecated https://github.com/astral-sh/ruff/issues/8796#issuecomment-2057143531 + "PT005", # deprecated https://github.com/astral-sh/ruff/issues/8796#issuecomment-2057143531 "PT007", # temporarily disabled, TODO: configure and standardize to preference "PT011", # temporarily disabled, TODO: tighten expected error "PT012", # pytest-raises-with-multiple-statements, avoid extra dummy methods for a few lines, sometimes we explicitly assert in case of no error @@ -76,8 +78,8 @@ ignore-fully-untyped = true [lint.flake8-pytest-style] parametrize-names-type = "csv" -# These default to false in preview mode, -# we'll be able to remove this config eventually +# These default to false in non-preview mode in Ruff 0.6, +# we'll be able to remove this config once raising our minimum version fixture-parentheses = false mark-parentheses = false diff --git a/setuptools/tests/fixtures.py b/setuptools/tests/fixtures.py index 03681785a20..a5472984b56 100644 --- a/setuptools/tests/fixtures.py +++ b/setuptools/tests/fixtures.py @@ -11,7 +11,7 @@ @pytest.fixture -def _user_override(monkeypatch): +def user_override(monkeypatch): """ Override site.USER_BASE and site.USER_SITE with temporary directories in a context. @@ -31,7 +31,7 @@ def tmpdir_cwd(tmpdir): @pytest.fixture(autouse=True, scope="session") -def _workaround_xdist_376(request): +def workaround_xdist_376(request): """ Workaround pytest-dev/pytest-xdist#376 diff --git a/setuptools/tests/integration/test_pip_install_sdist.py b/setuptools/tests/integration/test_pip_install_sdist.py index e1a634dba62..3302595e268 100644 --- a/setuptools/tests/integration/test_pip_install_sdist.py +++ b/setuptools/tests/integration/test_pip_install_sdist.py @@ -104,7 +104,7 @@ def venv_python(tmp_path): @pytest.fixture(autouse=True) -def _prepare(tmp_path, venv_python, monkeypatch): +def prepare(tmp_path, venv_python, monkeypatch): download_path = os.getenv("DOWNLOAD_PATH", str(tmp_path)) os.makedirs(download_path, exist_ok=True) diff --git a/setuptools/tests/test_bdist_egg.py b/setuptools/tests/test_bdist_egg.py index 24427fde3e7..036167dd951 100644 --- a/setuptools/tests/test_bdist_egg.py +++ b/setuptools/tests/test_bdist_egg.py @@ -28,7 +28,7 @@ def setup_context(tmpdir): class Test: - @pytest.mark.usefixtures("_user_override") + @pytest.mark.usefixtures("user_override") @pytest.mark.usefixtures("setup_context") def test_bdist_egg(self): dist = Distribution( @@ -52,7 +52,7 @@ def test_bdist_egg(self): os.environ.get('PYTHONDONTWRITEBYTECODE', False), reason="Byte code disabled", ) - @pytest.mark.usefixtures("_user_override") + @pytest.mark.usefixtures("user_override") @pytest.mark.usefixtures("setup_context") def test_exclude_source_files(self): dist = Distribution( diff --git a/setuptools/tests/test_develop.py b/setuptools/tests/test_develop.py index 6a96de0a0d0..929fa9c285e 100644 --- a/setuptools/tests/test_develop.py +++ b/setuptools/tests/test_develop.py @@ -27,7 +27,7 @@ @pytest.fixture -def _temp_user(monkeypatch): +def temp_user(monkeypatch): with contexts.tempdir() as user_base: with contexts.tempdir() as user_site: monkeypatch.setattr('site.USER_BASE', user_base) diff --git a/setuptools/tests/test_easy_install.py b/setuptools/tests/test_easy_install.py index 46412166e1a..a08cb83ae4c 100644 --- a/setuptools/tests/test_easy_install.py +++ b/setuptools/tests/test_easy_install.py @@ -39,7 +39,7 @@ @pytest.fixture(autouse=True) -def _pip_disable_index(monkeypatch): +def pip_disable_index(monkeypatch): """ Important: Disable the default index for pip to avoid querying packages in the index and potentially resolving @@ -367,7 +367,7 @@ def setup_context(tmpdir): yield tmpdir -@pytest.mark.usefixtures("_user_override") +@pytest.mark.usefixtures("user_override") @pytest.mark.usefixtures("setup_context") class TestUserInstallTest: # prevent check that site-packages is writable. easy_install @@ -461,7 +461,7 @@ def patched_setup_context(self): @pytest.fixture -def _distutils_package(): +def distutils_package(): distutils_setup_py = SETUP_PY.replace( 'from setuptools import setup', 'from distutils.core import setup', @@ -472,7 +472,7 @@ def _distutils_package(): yield -@pytest.mark.usefixtures("_distutils_package") +@pytest.mark.usefixtures("distutils_package") class TestDistutilsPackage: def test_bdist_egg_available_on_distutils_pkg(self): run_setup('setup.py', ['bdist_egg']) diff --git a/setuptools/tests/test_setuptools.py b/setuptools/tests/test_setuptools.py index 9c70c9a1f0e..a3b0fb4f5a0 100644 --- a/setuptools/tests/test_setuptools.py +++ b/setuptools/tests/test_setuptools.py @@ -20,7 +20,7 @@ @pytest.fixture(autouse=True) -def _isolated_dir(tmpdir_cwd): +def isolated_dir(tmpdir_cwd): return @@ -244,7 +244,7 @@ def test_findall_curdir(example_source): @pytest.fixture -def _can_symlink(tmpdir): +def can_symlink(tmpdir): """ Skip if cannot create a symbolic link """ @@ -257,7 +257,7 @@ def _can_symlink(tmpdir): os.remove(link_fn) -@pytest.mark.usefixtures("_can_symlink") +@pytest.mark.usefixtures("can_symlink") def test_findall_missing_symlink(tmpdir): with tmpdir.as_cwd(): os.symlink('foo', 'bar') diff --git a/setuptools/tests/test_virtualenv.py b/setuptools/tests/test_virtualenv.py index e3668a3129c..cdc10f50044 100644 --- a/setuptools/tests/test_virtualenv.py +++ b/setuptools/tests/test_virtualenv.py @@ -8,7 +8,7 @@ @pytest.fixture(autouse=True) -def _pytest_virtualenv_works(venv): +def pytest_virtualenv_works(venv): """ pytest_virtualenv may not work. if it doesn't, skip these tests. See #1284.