From 879ad202a7b02f00a6123aab18ee62dba67c8dc0 Mon Sep 17 00:00:00 2001 From: Avasam Date: Mon, 4 Nov 2024 13:16:13 -0500 Subject: [PATCH] Set Ruff's pytest's parametrize-names-type to default (tuple) --- pkg_resources/tests/test_pkg_resources.py | 8 ++++---- pkg_resources/tests/test_resources.py | 4 ++-- ruff.toml | 3 --- setuptools/tests/config/test_apply_pyprojecttoml.py | 11 ++++++----- setuptools/tests/config/test_expand.py | 6 +++--- setuptools/tests/config/test_pyprojecttoml.py | 4 ++-- .../tests/integration/test_pip_install_sdist.py | 2 +- setuptools/tests/test_bdist_wheel.py | 6 +++--- setuptools/tests/test_build_meta.py | 2 +- setuptools/tests/test_config_discovery.py | 8 ++++---- setuptools/tests/test_core_metadata.py | 6 +++--- setuptools/tests/test_dist.py | 8 ++++---- setuptools/tests/test_dist_info.py | 2 +- setuptools/tests/test_distutils_adoption.py | 4 ++-- setuptools/tests/test_egg_info.py | 6 +++--- setuptools/tests/test_glob.py | 2 +- setuptools/tests/test_logging.py | 2 +- setuptools/tests/test_wheel.py | 2 +- 18 files changed, 42 insertions(+), 44 deletions(-) diff --git a/pkg_resources/tests/test_pkg_resources.py b/pkg_resources/tests/test_pkg_resources.py index 18adb3c9d2..2e5526d1aa 100644 --- a/pkg_resources/tests/test_pkg_resources.py +++ b/pkg_resources/tests/test_pkg_resources.py @@ -236,7 +236,7 @@ def make_distribution_no_version(tmpdir, basename): @pytest.mark.parametrize( - 'suffix, expected_filename, expected_dist_type', + ("suffix", "expected_filename", "expected_dist_type"), [ ('egg-info', 'PKG-INFO', EggInfoDistribution), ('dist-info', 'METADATA', DistInfoDistribution), @@ -376,7 +376,7 @@ def test_version_resolved_from_egg_info(self, env): assert dist.version == version @pytest.mark.parametrize( - 'unnormalized, normalized', + ("unnormalized", "normalized"), [ ('foo', 'foo'), ('foo/', 'foo'), @@ -398,7 +398,7 @@ def test_normalize_path_trailing_sep(self, unnormalized, normalized): reason='Testing case-insensitive filesystems.', ) @pytest.mark.parametrize( - 'unnormalized, normalized', + ("unnormalized", "normalized"), [ ('MiXeD/CasE', 'mixed/case'), ], @@ -414,7 +414,7 @@ def test_normalize_path_normcase(self, unnormalized, normalized): reason='Testing systems using backslashes as path separators.', ) @pytest.mark.parametrize( - 'unnormalized, expected', + ("unnormalized", "expected"), [ ('forward/slash', 'forward\\slash'), ('forward/slash/', 'forward\\slash'), diff --git a/pkg_resources/tests/test_resources.py b/pkg_resources/tests/test_resources.py index a3097a85dc..be1c1213af 100644 --- a/pkg_resources/tests/test_resources.py +++ b/pkg_resources/tests/test_resources.py @@ -700,7 +700,7 @@ def test_spaces_between_multiple_versions(self): (req,) = parse_requirements('foo >= 1.0, < 3') @pytest.mark.parametrize( - 'lower, upper', + ("lower", "upper"), [ ('1.2-rc1', '1.2rc1'), ('0.4', '0.4.0'), @@ -724,7 +724,7 @@ def testVersionEquality(self, lower, upper): """ @pytest.mark.parametrize( - 'lower, upper', + ("lower", "upper"), [ ('2.1', '2.1.1'), ('2a1', '2b0'), diff --git a/ruff.toml b/ruff.toml index c6fbc173aa..9f20438943 100644 --- a/ruff.toml +++ b/ruff.toml @@ -81,9 +81,6 @@ sections.delayed = ["distutils"] [lint.flake8-annotations] ignore-fully-untyped = true -[lint.flake8-pytest-style] -parametrize-names-type = "csv" - [format] # Enable preview to get hugged parenthesis unwrapping and other nice surprises # See https://github.com/jaraco/skeleton/pull/133#issuecomment-2239538373 diff --git a/setuptools/tests/config/test_apply_pyprojecttoml.py b/setuptools/tests/config/test_apply_pyprojecttoml.py index e8b9eaf770..da43bb6a2b 100644 --- a/setuptools/tests/config/test_apply_pyprojecttoml.py +++ b/setuptools/tests/config/test_apply_pyprojecttoml.py @@ -183,7 +183,7 @@ def test_pep621_example(tmp_path): @pytest.mark.parametrize( - "readme, ctype", + ("readme", "ctype"), [ ("Readme.txt", "text/plain"), ("readme.md", "text/markdown"), @@ -209,7 +209,7 @@ def test_no_explicit_content_type_for_missing_extension(tmp_path): @pytest.mark.parametrize( - 'pyproject_text, expected_maintainers_meta_value', + ("pyproject_text", "expected_maintainers_meta_value"), ( pytest.param( PEP621_EXAMPLE, @@ -370,7 +370,7 @@ def pyproject(self, tmp_path, dynamic, extra_content=""): return file @pytest.mark.parametrize( - "attr, field, value", + ("attr", "field", "value"), [ ("classifiers", "classifiers", ["Private :: Classifier"]), ("entry_points", "scripts", {"console_scripts": ["foobar=foobar:main"]}), @@ -395,7 +395,7 @@ def test_not_listed_in_dynamic(self, tmp_path, attr, field, value): assert not dist_value @pytest.mark.parametrize( - "attr, field, value", + ("attr", "field", "value"), [ ("install_requires", "dependencies", []), ("extras_require", "optional-dependencies", {}), @@ -442,7 +442,8 @@ def test_optional_dependencies_dont_remove_env_markers(self, tmp_path): assert ':python_version < "3.7"' in reqs @pytest.mark.parametrize( - "field,group", [("scripts", "console_scripts"), ("gui-scripts", "gui_scripts")] + ("field", "group"), + [("scripts", "console_scripts"), ("gui-scripts", "gui_scripts")], ) @pytest.mark.filterwarnings("error") def test_scripts_dont_require_dynamic_entry_points(self, tmp_path, field, group): diff --git a/setuptools/tests/config/test_expand.py b/setuptools/tests/config/test_expand.py index f51d2008d0..fa9122b32c 100644 --- a/setuptools/tests/config/test_expand.py +++ b/setuptools/tests/config/test_expand.py @@ -141,7 +141,7 @@ def test_import_order(self, tmp_path): @pytest.mark.parametrize( - 'package_dir, file, module, return_value', + ("package_dir", "file", "module", "return_value"), [ ({"": "src"}, "src/pkg/main.py", "pkg.main", 42), ({"pkg": "lib"}, "lib/main.py", "pkg.main", 13), @@ -158,7 +158,7 @@ def test_resolve_class(monkeypatch, tmp_path, package_dir, file, module, return_ @pytest.mark.parametrize( - 'args, pkgs', + ("args", "pkgs"), [ ({"where": ["."], "namespaces": False}, {"pkg", "other"}), ({"where": [".", "dir1"], "namespaces": False}, {"pkg", "other", "dir2"}), @@ -192,7 +192,7 @@ def test_find_packages(tmp_path, args, pkgs): @pytest.mark.parametrize( - "files, where, expected_package_dir", + ("files", "where", "expected_package_dir"), [ (["pkg1/__init__.py", "pkg1/other.py"], ["."], {}), (["pkg1/__init__.py", "pkg2/__init__.py"], ["."], {}), diff --git a/setuptools/tests/config/test_pyprojecttoml.py b/setuptools/tests/config/test_pyprojecttoml.py index bb15ce10de..db40fcd23d 100644 --- a/setuptools/tests/config/test_pyprojecttoml.py +++ b/setuptools/tests/config/test_pyprojecttoml.py @@ -149,7 +149,7 @@ def test_read_configuration(tmp_path): @pytest.mark.parametrize( - "pkg_root, opts", + ("pkg_root", "opts"), [ (".", {}), ("src", {}), @@ -308,7 +308,7 @@ def test_ignore_unrelated_config(tmp_path, example): @pytest.mark.parametrize( - "example, error_msg", + ("example", "error_msg"), [ ( """ diff --git a/setuptools/tests/integration/test_pip_install_sdist.py b/setuptools/tests/integration/test_pip_install_sdist.py index 2e06f5e3cb..b2f1c08003 100644 --- a/setuptools/tests/integration/test_pip_install_sdist.py +++ b/setuptools/tests/integration/test_pip_install_sdist.py @@ -122,7 +122,7 @@ def _prepare(tmp_path, venv_python, monkeypatch): run([venv_python, "-m", "pip", "freeze"]) -@pytest.mark.parametrize('package, version', EXAMPLES) +@pytest.mark.parametrize(("package", "version"), EXAMPLES) @pytest.mark.uses_network def test_install_sdist(package, version, tmp_path, venv_python, setuptools_wheel): venv_pip = (venv_python, "-m", "pip") diff --git a/setuptools/tests/test_bdist_wheel.py b/setuptools/tests/test_bdist_wheel.py index 141ef716ab..3dfa9c850c 100644 --- a/setuptools/tests/test_bdist_wheel.py +++ b/setuptools/tests/test_bdist_wheel.py @@ -322,7 +322,7 @@ def test_licenses_deprecated(dummy_dist, monkeypatch, tmp_path): @pytest.mark.parametrize( - "config_file, config", + ("config_file", "config"), [ ("setup.cfg", "[metadata]\nlicense_files=licenses/*\n LICENSE"), ("setup.cfg", "[metadata]\nlicense_files=licenses/*, LICENSE"), @@ -434,7 +434,7 @@ def test_build_from_readonly_tree(dummy_dist, monkeypatch, tmp_path): @pytest.mark.parametrize( - "option, compress_type", + ("option", "compress_type"), list(bdist_wheel.supported_compressions.items()), ids=list(bdist_wheel.supported_compressions), ) @@ -589,7 +589,7 @@ def test_data_dir_with_tag_build(monkeypatch, tmp_path): @pytest.mark.parametrize( - "reported,expected", + ("reported", "expected"), [("linux-x86_64", "linux_i686"), ("linux-aarch64", "linux_armv7l")], ) @pytest.mark.skipif( diff --git a/setuptools/tests/test_build_meta.py b/setuptools/tests/test_build_meta.py index 53095afb52..121f409057 100644 --- a/setuptools/tests/test_build_meta.py +++ b/setuptools/tests/test_build_meta.py @@ -737,7 +737,7 @@ def test_editable_with_config_settings(self, tmpdir_cwd, config_settings): self._assert_link_tree(next(Path("build").glob("__editable__.*"))) @pytest.mark.parametrize( - 'setup_literal, requirements', + ("setup_literal", "requirements"), [ ("'foo'", ['foo']), ("['foo']", ['foo']), diff --git a/setuptools/tests/test_config_discovery.py b/setuptools/tests/test_config_discovery.py index 6b60c7e7f7..b5df8203cd 100644 --- a/setuptools/tests/test_config_discovery.py +++ b/setuptools/tests/test_config_discovery.py @@ -161,7 +161,7 @@ def test_project(self, tmp_path, circumstance): } @pytest.mark.parametrize( - "config_file, param, circumstance", + ("config_file", "param", "circumstance"), product( ["setup.cfg", "setup.py", "pyproject.toml"], ["packages", "py_modules"], @@ -191,7 +191,7 @@ def test_purposefully_empty(self, tmp_path, config_file, param, circumstance): assert getattr(dist, other) is None @pytest.mark.parametrize( - "extra_files, pkgs", + ("extra_files", "pkgs"), [ (["venv/bin/simulate_venv"], {"pkg"}), (["pkg-stubs/__init__.pyi"], {"pkg", "pkg-stubs"}), @@ -284,7 +284,7 @@ def test_build_with_discovered_name(self, tmp_path): class TestWithAttrDirective: @pytest.mark.parametrize( - "folder, opts", + ("folder", "opts"), [ ("src", {}), ("lib", {"packages": "find:", "packages.find": {"where": "lib"}}), @@ -446,7 +446,7 @@ def _simulate_package_with_data_files(self, tmp_path, src_root): """ @pytest.mark.parametrize( - "src_root, files", + ("src_root", "files"), [ (".", {"setup.cfg": DALS(EXAMPLE_SETUPCFG)}), (".", {"pyproject.toml": DALS(EXAMPLE_PYPROJECT)}), diff --git a/setuptools/tests/test_core_metadata.py b/setuptools/tests/test_core_metadata.py index 51d4a10810..2b585a9c91 100644 --- a/setuptools/tests/test_core_metadata.py +++ b/setuptools/tests/test_core_metadata.py @@ -23,7 +23,7 @@ @pytest.mark.parametrize( - 'content, result', + ("content", "result"), ( pytest.param( "Just a single line", @@ -154,7 +154,7 @@ def __read_test_cases(): ] -@pytest.mark.parametrize('name,attrs', __read_test_cases()) +@pytest.mark.parametrize(("name", "attrs"), __read_test_cases()) def test_read_metadata(name, attrs): dist = Distribution(attrs) metadata_out = dist.metadata @@ -263,7 +263,7 @@ def merge_dicts(d1, d2): ] -@pytest.mark.parametrize('name,attrs', __maintainer_test_cases()) +@pytest.mark.parametrize(("name", "attrs"), __maintainer_test_cases()) def test_maintainer_author(name, attrs, tmpdir): tested_keys = { 'author': 'Author', diff --git a/setuptools/tests/test_dist.py b/setuptools/tests/test_dist.py index 1bc4923032..be953079f5 100644 --- a/setuptools/tests/test_dist.py +++ b/setuptools/tests/test_dist.py @@ -129,7 +129,7 @@ def test_provides_extras_deterministic_order(): ) -@pytest.mark.parametrize('package_data, expected_message', CHECK_PACKAGE_DATA_TESTS) +@pytest.mark.parametrize(('package_data', 'expected_message'), CHECK_PACKAGE_DATA_TESTS) def test_check_package_data(package_data, expected_message): if expected_message is None: assert check_package_data(None, 'package_data', package_data) is None @@ -156,7 +156,7 @@ def test_metadata_name(): @pytest.mark.parametrize( - "dist_name, py_module", + ('dist_name', 'py_module'), [ ("my.pkg", "my_pkg"), ("my-pkg", "my_pkg"), @@ -187,7 +187,7 @@ def test_dist_default_py_modules(tmp_path, dist_name, py_module): @pytest.mark.parametrize( - "dist_name, package_dir, package_files, packages", + ('dist_name', 'package_dir', 'package_files', 'packages'), [ ("my.pkg", None, ["my_pkg/__init__.py", "my_pkg/mod.py"], ["my_pkg"]), ("my-pkg", None, ["my_pkg/__init__.py", "my_pkg/mod.py"], ["my_pkg"]), @@ -241,7 +241,7 @@ def test_dist_default_packages( @pytest.mark.parametrize( - "dist_name, package_dir, package_files", + ('dist_name', 'package_dir', 'package_files'), [ ("my.pkg.nested", None, ["my/pkg/nested/__init__.py"]), ("my.pkg", None, ["my/pkg/__init__.py", "my/pkg/file.py"]), diff --git a/setuptools/tests/test_dist_info.py b/setuptools/tests/test_dist_info.py index 6e109c9db2..31e6e95a68 100644 --- a/setuptools/tests/test_dist_info.py +++ b/setuptools/tests/test_dist_info.py @@ -169,7 +169,7 @@ class TestWheelCompatibility: @pytest.mark.parametrize("name", "my-proj my_proj my.proj My.Proj".split()) @pytest.mark.parametrize("version", ["0.42.13"]) - @pytest.mark.parametrize("suffix, cfg", EGG_INFO_OPTS) + @pytest.mark.parametrize(("suffix", "cfg"), EGG_INFO_OPTS) def test_dist_info_is_the_same_as_in_wheel( self, name, version, tmp_path, suffix, cfg ): diff --git a/setuptools/tests/test_distutils_adoption.py b/setuptools/tests/test_distutils_adoption.py index aabfdd283a..f99a588499 100644 --- a/setuptools/tests/test_distutils_adoption.py +++ b/setuptools/tests/test_distutils_adoption.py @@ -116,7 +116,7 @@ def test_distutils_has_origin(): @pytest.mark.usefixtures("tmpdir_cwd") @pytest.mark.parametrize( - "distutils_version, imported_module", + ('distutils_version', 'imported_module'), [ pytest.param("stdlib", "dir_util", marks=skip_without_stdlib_distutils), pytest.param("stdlib", "file_util", marks=skip_without_stdlib_distutils), @@ -175,7 +175,7 @@ def test_log_module_is_not_duplicated_on_import(distutils_version, venv): @pytest.mark.usefixtures("tmpdir_cwd") @pytest.mark.parametrize( - "distutils_version, imported_module", + ('distutils_version', 'imported_module'), [ ("local", "distutils"), # Unfortunately we still get ._distutils.errors.DistutilsError with SETUPTOOLS_USE_DISTUTILS=stdlib diff --git a/setuptools/tests/test_egg_info.py b/setuptools/tests/test_egg_info.py index f82d931eba..7b7433f0ba 100644 --- a/setuptools/tests/test_egg_info.py +++ b/setuptools/tests/test_egg_info.py @@ -543,7 +543,7 @@ def test_doesnt_provides_extra(self, tmpdir_cwd, env): assert 'Provides-Extra:' not in pkg_info_text @pytest.mark.parametrize( - "files, license_in_sources", + ('files', 'license_in_sources'), [ ( { @@ -627,7 +627,7 @@ def test_setup_cfg_license_file(self, tmpdir_cwd, env, files, license_in_sources assert 'INVALID_LICENSE' not in sources_text @pytest.mark.parametrize( - "files, incl_licenses, excl_licenses", + ('files', 'incl_licenses', 'excl_licenses'), [ ( { @@ -839,7 +839,7 @@ def test_setup_cfg_license_files( assert sources_lines.count(lf) == 0 @pytest.mark.parametrize( - "files, incl_licenses, excl_licenses", + ('files', 'incl_licenses', 'excl_licenses'), [ ( { diff --git a/setuptools/tests/test_glob.py b/setuptools/tests/test_glob.py index bdccba6c24..8d225a4461 100644 --- a/setuptools/tests/test_glob.py +++ b/setuptools/tests/test_glob.py @@ -5,7 +5,7 @@ @pytest.mark.parametrize( - 'tree, pattern, matches', + ('tree', 'pattern', 'matches'), ( ('', b'', []), ('', '', []), diff --git a/setuptools/tests/test_logging.py b/setuptools/tests/test_logging.py index e01df7277c..ea58001e93 100644 --- a/setuptools/tests/test_logging.py +++ b/setuptools/tests/test_logging.py @@ -19,7 +19,7 @@ @pytest.mark.parametrize( - "flag, expected_level", [("--dry-run", "INFO"), ("--verbose", "DEBUG")] + ('flag', 'expected_level'), [("--dry-run", "INFO"), ("--verbose", "DEBUG")] ) def test_verbosity_level(tmp_path, monkeypatch, flag, expected_level): """Make sure the correct verbosity level is set (issue #3038)""" diff --git a/setuptools/tests/test_wheel.py b/setuptools/tests/test_wheel.py index 4125e609f9..5724c6eabc 100644 --- a/setuptools/tests/test_wheel.py +++ b/setuptools/tests/test_wheel.py @@ -78,7 +78,7 @@ @pytest.mark.parametrize( - 'filename, info', WHEEL_INFO_TESTS, ids=[t[0] for t in WHEEL_INFO_TESTS] + ('filename', 'info'), WHEEL_INFO_TESTS, ids=[t[0] for t in WHEEL_INFO_TESTS] ) def test_wheel_info(filename, info): if inspect.isclass(info):