diff --git a/pkg_resources/tests/test_pkg_resources.py b/pkg_resources/tests/test_pkg_resources.py index cfc9b16c0f..3a6bd3de1e 100644 --- a/pkg_resources/tests/test_pkg_resources.py +++ b/pkg_resources/tests/test_pkg_resources.py @@ -262,7 +262,7 @@ def test_distribution_version_missing( metadata_path = os.path.join(dist_dir, expected_filename) # Now check the exception raised when the "version" attribute is accessed. - with pytest.raises(ValueError) as excinfo: + with pytest.raises(ValueError, match="xxxxx") as excinfo: dist.version err = str(excinfo.value) @@ -290,7 +290,7 @@ def test_distribution_version_missing_undetected_path(): # Create a Distribution object with no metadata argument, which results # in an empty metadata provider. dist = Distribution('/foo') - with pytest.raises(ValueError) as excinfo: + with pytest.raises(ValueError, match="xxxxx") as excinfo: dist.version msg, dist = excinfo.value.args diff --git a/pkg_resources/tests/test_resources.py b/pkg_resources/tests/test_resources.py index 70436c0881..5e82f6015d 100644 --- a/pkg_resources/tests/test_resources.py +++ b/pkg_resources/tests/test_resources.py @@ -460,7 +460,7 @@ def testParse(self): @pytest.mark.parametrize("reject_spec", reject_specs) def test_reject_spec(self, reject_spec): - with pytest.raises(ValueError): + with pytest.raises(ValueError, match=reject_spec): EntryPoint.parse(reject_spec) def test_printable_name(self): @@ -497,9 +497,9 @@ def checkSubMap(self, m): def testParseList(self): self.checkSubMap(EntryPoint.parse_group("xyz", self.submap_str)) - with pytest.raises(ValueError): + with pytest.raises(ValueError, match="xxxxx"): EntryPoint.parse_group("x a", "foo=bar") - with pytest.raises(ValueError): + with pytest.raises(ValueError, match="xxxxx"): EntryPoint.parse_group("x", ["foo=baz", "foo=bar"]) def testParseMap(self): @@ -509,9 +509,9 @@ def testParseMap(self): m = EntryPoint.parse_map("[xyz]\n" + self.submap_str) self.checkSubMap(m['xyz']) assert list(m.keys()) == ['xyz'] - with pytest.raises(ValueError): + with pytest.raises(ValueError, match="xxxxx"): EntryPoint.parse_map(["[xyz]", "[xyz]"]) - with pytest.raises(ValueError): + with pytest.raises(ValueError, match="xxxxx"): EntryPoint.parse_map(self.submap_str) def testDeprecationWarnings(self): @@ -642,7 +642,7 @@ def testSplitting(self): ("d", []), ("q", ["v"]), ] - with pytest.raises(ValueError): + with pytest.raises(ValueError, match="xxxxx"): list(pkg_resources.split_sections("[foo")) def testSafeName(self): @@ -667,15 +667,15 @@ def testSimpleRequirements(self): Requirement('Twisted>=1.2,<2.0') ] assert Requirement.parse("FooBar==1.99a3") == Requirement("FooBar==1.99a3") - with pytest.raises(ValueError): + with pytest.raises(ValueError, match=r" >=2\.3"): Requirement.parse(">=2.3") - with pytest.raises(ValueError): + with pytest.raises(ValueError, match="xxxxx"): Requirement.parse("x\\") - with pytest.raises(ValueError): + with pytest.raises(ValueError, match="xxxxx"): Requirement.parse("x==2 q") - with pytest.raises(ValueError): + with pytest.raises(ValueError, match="xxxxx"): Requirement.parse("X==1\nY==2") - with pytest.raises(ValueError): + with pytest.raises(ValueError, match="xxxxx"): Requirement.parse("#") def test_requirements_with_markers(self): diff --git a/setuptools/tests/config/test_apply_pyprojecttoml.py b/setuptools/tests/config/test_apply_pyprojecttoml.py index 489fd98e26..16d2346e40 100644 --- a/setuptools/tests/config/test_apply_pyprojecttoml.py +++ b/setuptools/tests/config/test_apply_pyprojecttoml.py @@ -248,7 +248,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, ( @@ -267,7 +267,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, diff --git a/setuptools/tests/config/test_pyprojecttoml.py b/setuptools/tests/config/test_pyprojecttoml.py index db40fcd23d..fae08ca5b1 100644 --- a/setuptools/tests/config/test_pyprojecttoml.py +++ b/setuptools/tests/config/test_pyprojecttoml.py @@ -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} @@ -288,7 +288,7 @@ def test_dynamic_without_file(self, tmp_path): @pytest.mark.parametrize( "example", - ( + [ """ [project] name = "myproj" @@ -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" @@ -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") @@ -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. diff --git a/setuptools/tests/config/test_setupcfg.py b/setuptools/tests/config/test_setupcfg.py index 61af990447..f69b7059d5 100644 --- a/setuptools/tests/config/test_setupcfg.py +++ b/setuptools/tests/config/test_setupcfg.py @@ -897,9 +897,9 @@ def test_python_requires_invalid(self, tmpdir): """ ), ) - with pytest.raises(Exception): - with get_dist(tmpdir) as dist: - dist.parse_config_files() + ############# with pytest.raises(Exception): + with get_dist(tmpdir) as dist: + dist.parse_config_files() def test_cmdclass(self, tmpdir): module_path = Path(tmpdir, "src/custom_build.py") # auto discovery for src diff --git a/setuptools/tests/test_build_meta.py b/setuptools/tests/test_build_meta.py index 624bba862e..11f2cd8d56 100644 --- a/setuptools/tests/test_build_meta.py +++ b/setuptools/tests/test_build_meta.py @@ -265,7 +265,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. @@ -908,7 +908,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) diff --git a/setuptools/tests/test_core_metadata.py b/setuptools/tests/test_core_metadata.py index 0d925111fa..cc7494da24 100644 --- a/setuptools/tests/test_core_metadata.py +++ b/setuptools/tests/test_core_metadata.py @@ -38,7 +38,7 @@ @pytest.mark.parametrize( ("content", "result"), - ( + [ pytest.param( "Just a single line", None, @@ -64,7 +64,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)) diff --git a/setuptools/tests/test_dist_info.py b/setuptools/tests/test_dist_info.py index 426694e019..38f12cb5bf 100644 --- a/setuptools/tests/test_dist_info.py +++ b/setuptools/tests/test_dist_info.py @@ -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") diff --git a/setuptools/tests/test_easy_install.py b/setuptools/tests/test_easy_install.py index b58b0b6666..59979ed7ea 100644 --- a/setuptools/tests/test_easy_install.py +++ b/setuptools/tests/test_easy_install.py @@ -907,7 +907,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 ): diff --git a/setuptools/tests/test_editable_install.py b/setuptools/tests/test_editable_install.py index 038dcadf93..c0dd76fba2 100644 --- a/setuptools/tests/test_editable_install.py +++ b/setuptools/tests/test_editable_install.py @@ -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 ): diff --git a/setuptools/tests/test_glob.py b/setuptools/tests/test_glob.py index 8d225a4461..5ef9a19ac6 100644 --- a/setuptools/tests/test_glob.py +++ b/setuptools/tests/test_glob.py @@ -6,7 +6,7 @@ @pytest.mark.parametrize( ('tree', 'pattern', 'matches'), - ( + [ ('', b'', []), ('', '', []), ( @@ -37,7 +37,7 @@ b'*.rst', (b'CHANGES.rst', b'README.rst'), ), - ), + ], ) def test_glob(monkeypatch, tmpdir, tree, pattern, matches): monkeypatch.chdir(tmpdir) diff --git a/setuptools/tests/test_sandbox.py b/setuptools/tests/test_sandbox.py index a476b7c93d..4c9e0bd5da 100644 --- a/setuptools/tests/test_sandbox.py +++ b/setuptools/tests/test_sandbox.py @@ -47,7 +47,7 @@ def test_exception_resumed(self): with setuptools.sandbox.ExceptionSaver() as saved_exc: raise ValueError("details") - with pytest.raises(ValueError) as caught: + with pytest.raises(ValueError, match="details") as caught: saved_exc.resume() assert isinstance(caught.value, ValueError) @@ -59,7 +59,7 @@ def test_exception_reconstructed(self): with setuptools.sandbox.ExceptionSaver() as saved_exc: raise orig_exc - with pytest.raises(ValueError) as caught: + with pytest.raises(ValueError, match="details") as caught: saved_exc.resume() assert isinstance(caught.value, ValueError) diff --git a/setuptools/tests/test_sdist.py b/setuptools/tests/test_sdist.py index 19d8ddf6da..ca3af3f9c9 100644 --- a/setuptools/tests/test_sdist.py +++ b/setuptools/tests/test_sdist.py @@ -903,7 +903,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 @@ -951,7 +951,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 diff --git a/setuptools/tests/test_wheel.py b/setuptools/tests/test_wheel.py index 70165c608b..21beb5992d 100644 --- a/setuptools/tests/test_wheel.py +++ b/setuptools/tests/test_wheel.py @@ -609,7 +609,7 @@ def test_wheel_no_dist_dir(): # create an empty zip file zipfile.ZipFile(wheel_path, 'w').close() with tempdir() as install_dir: - with pytest.raises(ValueError): + with pytest.raises(ValueError, match=r"\.dist-info not found"): _check_wheel_install( wheel_path, install_dir, None, project_name, version, None )