Skip to content

Commit

Permalink
Set Ruff's pytest's parametrize-names-type to default (tuple)
Browse files Browse the repository at this point in the history
  • Loading branch information
Avasam committed Nov 4, 2024
1 parent b27393a commit 879ad20
Show file tree
Hide file tree
Showing 18 changed files with 42 additions and 44 deletions.
8 changes: 4 additions & 4 deletions pkg_resources/tests/test_pkg_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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'),
Expand All @@ -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'),
],
Expand All @@ -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'),
Expand Down
4 changes: 2 additions & 2 deletions pkg_resources/tests/test_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand All @@ -724,7 +724,7 @@ def testVersionEquality(self, lower, upper):
"""

@pytest.mark.parametrize(
'lower, upper',
("lower", "upper"),
[
('2.1', '2.1.1'),
('2a1', '2b0'),
Expand Down
3 changes: 0 additions & 3 deletions ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 6 additions & 5 deletions setuptools/tests/config/test_apply_pyprojecttoml.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand All @@ -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,
Expand Down Expand Up @@ -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"]}),
Expand All @@ -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", {}),
Expand Down Expand Up @@ -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):
Expand Down
6 changes: 3 additions & 3 deletions setuptools/tests/config/test_expand.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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"}),
Expand Down Expand Up @@ -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"], ["."], {}),
Expand Down
4 changes: 2 additions & 2 deletions setuptools/tests/config/test_pyprojecttoml.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def test_read_configuration(tmp_path):


@pytest.mark.parametrize(
"pkg_root, opts",
("pkg_root", "opts"),
[
(".", {}),
("src", {}),
Expand Down Expand Up @@ -308,7 +308,7 @@ def test_ignore_unrelated_config(tmp_path, example):


@pytest.mark.parametrize(
"example, error_msg",
("example", "error_msg"),
[
(
"""
Expand Down
2 changes: 1 addition & 1 deletion setuptools/tests/integration/test_pip_install_sdist.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
6 changes: 3 additions & 3 deletions setuptools/tests/test_bdist_wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down Expand Up @@ -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),
)
Expand Down Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion setuptools/tests/test_build_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']),
Expand Down
8 changes: 4 additions & 4 deletions setuptools/tests/test_config_discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand Down Expand Up @@ -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"}),
Expand Down Expand Up @@ -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"}}),
Expand Down Expand Up @@ -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)}),
Expand Down
6 changes: 3 additions & 3 deletions setuptools/tests/test_core_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@


@pytest.mark.parametrize(
'content, result',
("content", "result"),
(
pytest.param(
"Just a single line",
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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',
Expand Down
8 changes: 4 additions & 4 deletions setuptools/tests/test_dist.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"),
Expand Down Expand Up @@ -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"]),
Expand Down Expand Up @@ -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"]),
Expand Down
2 changes: 1 addition & 1 deletion setuptools/tests/test_dist_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
):
Expand Down
4 changes: 2 additions & 2 deletions setuptools/tests/test_distutils_adoption.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions setuptools/tests/test_egg_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
[
(
{
Expand Down Expand Up @@ -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'),
[
(
{
Expand Down Expand Up @@ -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'),
[
(
{
Expand Down
2 changes: 1 addition & 1 deletion setuptools/tests/test_glob.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


@pytest.mark.parametrize(
'tree, pattern, matches',
('tree', 'pattern', 'matches'),
(
('', b'', []),
('', '', []),
Expand Down
2 changes: 1 addition & 1 deletion setuptools/tests/test_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)"""
Expand Down
2 changes: 1 addition & 1 deletion setuptools/tests/test_wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 879ad20

Please sign in to comment.