Skip to content

Commit

Permalink
Enforce ruff/flake8-pytest-style rule PT007
Browse files Browse the repository at this point in the history
PT007 Wrong values type in `@pytest.mark.parametrize` expected `list` of `tuple`

I used the default style because it minimises changes to the current codebase:
	[lint.flake8-pytest-style]
	parametrize-values-type = "list"
	parametrize-values-row-type = "tuple"
  • Loading branch information
DimitriPapadopoulos committed Dec 31, 2024
1 parent 9362d9a commit 3469642
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 21 deletions.
1 change: 0 additions & 1 deletion ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ extend-select = [
]
ignore = [
"PERF203", # try-except-in-loop, micro-optimisation with many false-positive. Worth checking but don't block CI
"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
"TRY003", # raise-vanilla-args, avoid multitude of exception classes
Expand Down
4 changes: 2 additions & 2 deletions setuptools/tests/config/test_apply_pyprojecttoml.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ def test_no_explicit_content_type_for_missing_extension(tmp_path):

@pytest.mark.parametrize(
("pyproject_text", "expected_maintainers_meta_value"),
(
[
pytest.param(
PEP621_EXAMPLE,
(
Expand All @@ -229,7 +229,7 @@ def test_no_explicit_content_type_for_missing_extension(tmp_path):
),
id='international-email',
),
),
],
)
def test_utf8_maintainer_in_metadata( # issue-3663
expected_maintainers_meta_value,
Expand Down
10 changes: 5 additions & 5 deletions setuptools/tests/config/test_pyprojecttoml.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ def test_all_listed_in_dynamic(self, tmp_path):
assert len(expanded_project["entry-points"]) == 1
assert expanded_project["entry-points"]["other"]["c"] == "mod.c:func [extra]"

@pytest.mark.parametrize("missing_dynamic", ("scripts", "gui-scripts"))
@pytest.mark.parametrize("missing_dynamic", ["scripts", "gui-scripts"])
def test_scripts_not_listed_in_dynamic(self, tmp_path, missing_dynamic):
self.write_entry_points(tmp_path)
dynamic = {"scripts", "gui-scripts", "entry-points"} - {missing_dynamic}
Expand Down Expand Up @@ -288,7 +288,7 @@ def test_dynamic_without_file(self, tmp_path):

@pytest.mark.parametrize(
"example",
(
[
"""
[project]
name = "myproj"
Expand All @@ -297,7 +297,7 @@ def test_dynamic_without_file(self, tmp_path):
[my-tool.that-disrespect.pep518]
value = 42
""",
),
],
)
def test_ignore_unrelated_config(tmp_path, example):
pyproject = tmp_path / "pyproject.toml"
Expand Down Expand Up @@ -330,7 +330,7 @@ def test_invalid_example(tmp_path, example, error_msg):
read_configuration(pyproject)


@pytest.mark.parametrize("config", ("", "[tool.something]\nvalue = 42"))
@pytest.mark.parametrize("config", ["", "[tool.something]\nvalue = 42"])
def test_empty(tmp_path, config):
pyproject = tmp_path / "pyproject.toml"
pyproject.write_text(config, encoding="utf-8")
Expand All @@ -339,7 +339,7 @@ def test_empty(tmp_path, config):
assert read_configuration(pyproject) == {}


@pytest.mark.parametrize("config", ("[project]\nname = 'myproj'\nversion='42'\n",))
@pytest.mark.parametrize("config", ["[project]\nname = 'myproj'\nversion='42'\n"])
def test_include_package_data_by_default(tmp_path, config):
"""Builds with ``pyproject.toml`` should consider ``include-package-data=True`` as
default.
Expand Down
4 changes: 2 additions & 2 deletions setuptools/tests/test_build_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ def test_build_wheel(self, build_backend):
modules = [f for f in python_scripts if not f.endswith('setup.py')]
assert len(modules) == 1

@pytest.mark.parametrize('build_type', ('wheel', 'sdist'))
@pytest.mark.parametrize('build_type', ['wheel', 'sdist'])
def test_build_with_existing_file_present(self, build_type, tmpdir_cwd):
# Building a sdist/wheel should still succeed if there's
# already a sdist/wheel in the destination directory.
Expand Down Expand Up @@ -895,7 +895,7 @@ def test_setup_py_file_abspath(self, tmpdir_cwd):
build_backend = self.get_build_backend()
build_backend.build_sdist("temp")

@pytest.mark.parametrize('build_hook', ('build_sdist', 'build_wheel'))
@pytest.mark.parametrize('build_hook', ['build_sdist', 'build_wheel'])
def test_build_with_empty_setuppy(self, build_backend, build_hook):
files = {'setup.py': ''}
path.build(files)
Expand Down
4 changes: 2 additions & 2 deletions setuptools/tests/test_core_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

@pytest.mark.parametrize(
("content", "result"),
(
[
pytest.param(
"Just a single line",
None,
Expand All @@ -62,7 +62,7 @@
"Leading whitespace\nIn\n Multiline comment",
id="remove_leading_whitespace_multiline",
),
),
],
)
def test_rfc822_unescape(content, result):
assert (result or content) == rfc822_unescape(rfc822_escape(content))
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 @@ -112,7 +112,7 @@ def test_tag_arguments(self, tmp_path):
dist_info = next(tmp_path.glob("*.dist-info"))
assert dist_info.name.startswith("proj-42a")

@pytest.mark.parametrize("keep_egg_info", (False, True))
@pytest.mark.parametrize("keep_egg_info", [False, True])
def test_output_dir(self, tmp_path, keep_egg_info):
config = "[metadata]\nname=proj\nversion=42\n"
(tmp_path / "setup.cfg").write_text(config, encoding="utf-8")
Expand Down
2 changes: 1 addition & 1 deletion setuptools/tests/test_easy_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -906,7 +906,7 @@ def test_setup_requires_with_python_requires(self, monkeypatch, tmpdir):
)
assert eggs == ['dep 1.0']

@pytest.mark.parametrize('with_dependency_links_in_setup_py', (False, True))
@pytest.mark.parametrize('with_dependency_links_in_setup_py', [False, True])
def test_setup_requires_with_find_links_in_setup_cfg(
self, monkeypatch, with_dependency_links_in_setup_py
):
Expand Down
6 changes: 3 additions & 3 deletions setuptools/tests/test_editable_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,12 +263,12 @@ def test_nspkg_file_is_unique(self, tmp_path, monkeypatch):

@pytest.mark.parametrize(
"impl",
(
[
"pkg_resources",
# "pkgutil", => does not work
),
],
)
@pytest.mark.parametrize("ns", ("myns.n",))
@pytest.mark.parametrize("ns", ["myns.n"])
def test_namespace_package_importable(
self, venv, tmp_path, ns, impl, editable_opts
):
Expand Down
4 changes: 2 additions & 2 deletions setuptools/tests/test_glob.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

@pytest.mark.parametrize(
('tree', 'pattern', 'matches'),
(
[
('', b'', []),
('', '', []),
(
Expand Down Expand Up @@ -37,7 +37,7 @@
b'*.rst',
(b'CHANGES.rst', b'README.rst'),
),
),
],
)
def test_glob(monkeypatch, tmpdir, tree, pattern, matches):
monkeypatch.chdir(tmpdir)
Expand Down
4 changes: 2 additions & 2 deletions setuptools/tests/test_sdist.py
Original file line number Diff line number Diff line change
Expand Up @@ -894,7 +894,7 @@ def files_for_symlink_in_extension_depends(tmp_path, dep_path):
}

@pytest.mark.parametrize(
"dep_path", ("myheaders/dir/file.h", "myheaders/dir/../dir/file.h")
"dep_path", ["myheaders/dir/file.h", "myheaders/dir/../dir/file.h"]
)
def test_symlink_in_extension_depends(self, monkeypatch, tmp_path, dep_path):
# Given a project with a symlinked dir and a "depends" targeting that dir
Expand Down Expand Up @@ -942,7 +942,7 @@ def files_for_external_path_in_extension_depends(tmp_path, dep_path):
}

@pytest.mark.parametrize(
"dep_path", ("$tmp_path$/external/dir/file.h", "../external/dir/file.h")
"dep_path", ["$tmp_path$/external/dir/file.h", "../external/dir/file.h"]
)
def test_external_path_in_extension_depends(self, monkeypatch, tmp_path, dep_path):
# Given a project with a "depends" targeting an external dir
Expand Down

0 comments on commit 3469642

Please sign in to comment.