diff --git a/testing/acceptance_test.py b/testing/acceptance_test.py index 8f7be14beb4..f65a60b44c4 100644 --- a/testing/acceptance_test.py +++ b/testing/acceptance_test.py @@ -606,7 +606,7 @@ def test_python_pytest_package(self, testdir): def test_equivalence_pytest_pytest(self): assert pytest.main == py.test.cmdline.main - def test_invoke_with_invalid_type(self, capsys): + def test_invoke_with_invalid_type(self): with pytest.raises( TypeError, match="expected to be a list or tuple of strings, got: '-h'" ): @@ -617,7 +617,7 @@ def test_invoke_with_path(self, tmpdir, capsys): assert retcode == ExitCode.NO_TESTS_COLLECTED out, err = capsys.readouterr() - def test_invoke_plugin_api(self, testdir, capsys): + def test_invoke_plugin_api(self, capsys): class MyPlugin: def pytest_addoption(self, parser): parser.addoption("--myopt") diff --git a/testing/conftest.py b/testing/conftest.py index 8b0430f6927..33b817a1226 100644 --- a/testing/conftest.py +++ b/testing/conftest.py @@ -17,7 +17,7 @@ def restore_tracing(): @pytest.hookimpl(hookwrapper=True, tryfirst=True) -def pytest_collection_modifyitems(config, items): +def pytest_collection_modifyitems(items): """Prefer faster tests. Use a hookwrapper to do this in the beginning, so e.g. --ff still works diff --git a/testing/logging/test_reporting.py b/testing/logging/test_reporting.py index 5b24ef963af..201f42f32fb 100644 --- a/testing/logging/test_reporting.py +++ b/testing/logging/test_reporting.py @@ -626,7 +626,7 @@ def test_log_cli(request): "cli_args", ["", "--log-level=WARNING", "--log-file-level=WARNING", "--log-cli-level=WARNING"], ) -def test_log_cli_auto_enable(testdir, request, cli_args): +def test_log_cli_auto_enable(testdir, cli_args): """Check that live logs are enabled if --log-level or --log-cli-level is passed on the CLI. It should not be auto enabled if the same configs are set on the INI file. """ diff --git a/testing/python/collect.py b/testing/python/collect.py index 30f9841b565..6e993822750 100644 --- a/testing/python/collect.py +++ b/testing/python/collect.py @@ -286,7 +286,7 @@ def make_function(testdir, **kwargs): return pytest.Function(config=config, parent=session, **kwargs) - def test_function_equality(self, testdir, tmpdir): + def test_function_equality(self, testdir): def func1(): pass @@ -492,7 +492,7 @@ def test_function(arg): ) assert "foo" in keywords[1] and "bar" in keywords[1] and "baz" in keywords[1] - def test_function_equality_with_callspec(self, testdir, tmpdir): + def test_function_equality_with_callspec(self, testdir): items = testdir.getitems( """ import pytest @@ -509,11 +509,11 @@ def test_pyfunc_call(self, testdir): config = item.config class MyPlugin1: - def pytest_pyfunc_call(self, pyfuncitem): + def pytest_pyfunc_call(self): raise ValueError class MyPlugin2: - def pytest_pyfunc_call(self, pyfuncitem): + def pytest_pyfunc_call(self): return True config.pluginmanager.register(MyPlugin1()) @@ -1015,7 +1015,7 @@ def foo(): class TestReportInfo: - def test_itemreport_reportinfo(self, testdir, linecomp): + def test_itemreport_reportinfo(self, testdir): testdir.makeconftest( """ import pytest diff --git a/testing/python/fixtures.py b/testing/python/fixtures.py index 3e3b41812f0..6b8565237b1 100644 --- a/testing/python/fixtures.py +++ b/testing/python/fixtures.py @@ -4238,7 +4238,7 @@ def test_fixture_named_request(testdir): ) -def test_fixture_duplicated_arguments(testdir): +def test_fixture_duplicated_arguments(): """Raise error if there are positional and keyword arguments for the same parameter (#1682).""" with pytest.raises(TypeError) as excinfo: @@ -4253,7 +4253,7 @@ def arg(arg): ) -def test_fixture_with_positionals(testdir): +def test_fixture_with_positionals(): """Raise warning, but the positionals should still works (#1682).""" from _pytest.deprecated import FIXTURE_POSITIONAL_ARGUMENTS diff --git a/testing/python/metafunc.py b/testing/python/metafunc.py index 65855f724ac..452b6e73235 100644 --- a/testing/python/metafunc.py +++ b/testing/python/metafunc.py @@ -31,7 +31,7 @@ class DefinitionMock(python.FunctionDefinition): definition = DefinitionMock(func) return python.Metafunc(definition, fixtureinfo, config) - def test_no_funcargs(self, testdir): + def test_no_funcargs(self): def function(): pass @@ -61,7 +61,7 @@ def func(x, y): pytest.raises(ValueError, lambda: metafunc.parametrize("y", [5, 6])) pytest.raises(ValueError, lambda: metafunc.parametrize("y", [5, 6])) - def test_parametrize_bad_scope(self, testdir): + def test_parametrize_bad_scope(self): def func(x): pass @@ -153,7 +153,7 @@ def func(x): ids = [x.id for x in metafunc._calls] assert ids == ["basic", "advanced"] - def test_parametrize_with_wrong_number_of_ids(self, testdir): + def test_parametrize_with_wrong_number_of_ids(self): def func(x, y): pass @@ -652,7 +652,7 @@ def test_simple(x,y): result = testdir.runpytest("-v") result.stdout.fnmatch_lines(["*test_simple*a-b*", "*1 passed*"]) - def test_parametrize_indirect_list_error(self, testdir): + def test_parametrize_indirect_list_error(self): """#714""" def func(x, y): diff --git a/testing/test_assertion.py b/testing/test_assertion.py index e4d68ff8c10..5c0425829ab 100644 --- a/testing/test_assertion.py +++ b/testing/test_assertion.py @@ -1299,7 +1299,7 @@ def test_hello(): ) -def test_diff_newline_at_end(monkeypatch, testdir): +def test_diff_newline_at_end(testdir): testdir.makepyfile( r""" def test_diff(): @@ -1354,7 +1354,7 @@ def test_tuple(): assert "WR1" not in output -def test_assert_with_unicode(monkeypatch, testdir): +def test_assert_with_unicode(testdir): testdir.makepyfile( """\ def test_unicode(): diff --git a/testing/test_capture.py b/testing/test_capture.py index 94af3aef75c..0fac41a9907 100644 --- a/testing/test_capture.py +++ b/testing/test_capture.py @@ -937,7 +937,7 @@ def test_stderr(self): cap.done() assert s == "hello\n" - def test_stdin(self, tmpfile): + def test_stdin(self): cap = capture.FDCapture(0) cap.start() x = os.read(0, 100).strip() @@ -958,7 +958,7 @@ def test_writeorg(self, tmpfile): stmp = stmp_file.read() assert stmp == data2 - def test_simple_resume_suspend(self, tmpfile): + def test_simple_resume_suspend(self): with saved_fd(1): cap = capture.FDCapture(1) cap.start() diff --git a/testing/test_collection.py b/testing/test_collection.py index b791ac6f9be..62de0b9531e 100644 --- a/testing/test_collection.py +++ b/testing/test_collection.py @@ -243,7 +243,7 @@ def test_pytest_collect_file(self, testdir): wascalled = [] class Plugin: - def pytest_collect_file(self, path, parent): + def pytest_collect_file(self, path): if not path.basename.startswith("."): # Ignore hidden files, e.g. .testmondata. wascalled.append(path) @@ -257,7 +257,7 @@ def test_pytest_collect_directory(self, testdir): wascalled = [] class Plugin: - def pytest_collect_directory(self, path, parent): + def pytest_collect_directory(self, path): wascalled.append(path.basename) testdir.mkdir("hello") @@ -1173,7 +1173,7 @@ def test_nodeid(request): assert result.ret == 0 -def test_collectignore_via_conftest(testdir, monkeypatch): +def test_collectignore_via_conftest(testdir): """collect_ignore in parent conftest skips importing child (issue #4592).""" tests = testdir.mkpydir("tests") tests.ensure("conftest.py").write("collect_ignore = ['ignore_me']") diff --git a/testing/test_conftest.py b/testing/test_conftest.py index 2918ff04c5f..9e893152d1a 100644 --- a/testing/test_conftest.py +++ b/testing/test_conftest.py @@ -357,7 +357,7 @@ def impct(p): assert conftest._getconftestmodules(sub) == [ct1, ct2] -def test_fixture_dependency(testdir, monkeypatch): +def test_fixture_dependency(testdir): ct1 = testdir.makeconftest("") ct1 = testdir.makepyfile("__init__.py") ct1.write("") diff --git a/testing/test_faulthandler.py b/testing/test_faulthandler.py index e99206a4d2a..73bb66cf8fa 100644 --- a/testing/test_faulthandler.py +++ b/testing/test_faulthandler.py @@ -82,7 +82,7 @@ def test_timeout(): @pytest.mark.parametrize("hook_name", ["pytest_enter_pdb", "pytest_exception_interact"]) -def test_cancel_timeout_on_hook(monkeypatch, pytestconfig, hook_name): +def test_cancel_timeout_on_hook(monkeypatch, hook_name): """Make sure that we are cancelling any scheduled traceback dumping due to timeout before entering pdb (pytest-dev/pytest-faulthandler#12) or any other interactive exception (pytest-dev/pytest-faulthandler#14). diff --git a/testing/test_helpconfig.py b/testing/test_helpconfig.py index 962750f7b3a..1dee5b0f51d 100644 --- a/testing/test_helpconfig.py +++ b/testing/test_helpconfig.py @@ -57,7 +57,7 @@ def test_traceconfig(testdir): result.stdout.fnmatch_lines(["*using*pytest*py*", "*active plugins*"]) -def test_debug(testdir, monkeypatch): +def test_debug(testdir): result = testdir.runpytest_subprocess("--debug") assert result.ret == ExitCode.NO_TESTS_COLLECTED p = testdir.tmpdir.join("pytestdebug.log") diff --git a/testing/test_mark.py b/testing/test_mark.py index 0e44220259c..3993224a5b1 100644 --- a/testing/test_mark.py +++ b/testing/test_mark.py @@ -41,7 +41,7 @@ def test_pytest_mark_name_starts_with_underscore(self): mark._some_name -def test_marked_class_run_twice(testdir, request): +def test_marked_class_run_twice(testdir): """Test fails file is run twice that contains marked class. See issue#683. """ diff --git a/testing/test_parseopt.py b/testing/test_parseopt.py index 915747378f5..ded5167d8da 100644 --- a/testing/test_parseopt.py +++ b/testing/test_parseopt.py @@ -254,14 +254,14 @@ def test_drop_short_3(self, parser): assert args.func_arg is False assert args.file_or_dir == ["abcd"] - def test_drop_short_help0(self, parser, capsys): + def test_drop_short_help0(self, parser): parser.addoption("--func-args", "--doit", help="foo", action="store_true") parser.parse([]) help = parser.optparser.format_help() assert "--func-args, --doit foo" in help # testing would be more helpful with all help generated - def test_drop_short_help1(self, parser, capsys): + def test_drop_short_help1(self, parser): group = parser.getgroup("general") group.addoption("--doit", "--func-args", action="store_true", help="foo") group._addoption( diff --git a/testing/test_pdb.py b/testing/test_pdb.py index 25d2292e9cb..6b1af938433 100644 --- a/testing/test_pdb.py +++ b/testing/test_pdb.py @@ -463,7 +463,7 @@ def test_2(): child.read() self.flush(child) - def test_pdb_interaction_doctest(self, testdir, monkeypatch): + def test_pdb_interaction_doctest(self, testdir): p1 = testdir.makepyfile( """ def function_1(): @@ -489,7 +489,7 @@ def function_1(): assert "1 failed" in rest self.flush(child) - def test_doctest_set_trace_quit(self, testdir, monkeypatch): + def test_doctest_set_trace_quit(self, testdir): p1 = testdir.makepyfile( """ def function_1(): @@ -833,7 +833,7 @@ def test_pdb_custom_cls_invalid(self, testdir): ] ) - def test_pdb_validate_usepdb_cls(self, testdir): + def test_pdb_validate_usepdb_cls(self): assert _validate_usepdb_cls("os.path:dirname.__name__") == ( "os.path", "dirname.__name__", diff --git a/testing/test_pluginmanager.py b/testing/test_pluginmanager.py index 836b458c6e4..e3402d20701 100644 --- a/testing/test_pluginmanager.py +++ b/testing/test_pluginmanager.py @@ -71,7 +71,7 @@ def test_configure(self, testdir): values = [] class A: - def pytest_configure(self, config): + def pytest_configure(self): values.append(self) config.pluginmanager.register(A()) diff --git a/testing/test_terminal.py b/testing/test_terminal.py index fa45c48da36..37f1eca893d 100644 --- a/testing/test_terminal.py +++ b/testing/test_terminal.py @@ -621,7 +621,7 @@ def test_passes(): if request.config.pluginmanager.list_plugin_distinfo(): result.stdout.fnmatch_lines(["plugins: *"]) - def test_header(self, testdir, request): + def test_header(self, testdir): testdir.tmpdir.join("tests").ensure_dir() testdir.tmpdir.join("gui").ensure_dir() @@ -687,7 +687,7 @@ def check(x): """ ) - def test_verbose_reporting(self, verbose_testfile, testdir, pytestconfig): + def test_verbose_reporting(self, verbose_testfile, testdir): result = testdir.runpytest( verbose_testfile, "-v", "-Walways::pytest.PytestWarning" ) @@ -943,7 +943,7 @@ def test_opt(arg): assert "assert x" in s -def test_traceconfig(testdir, monkeypatch): +def test_traceconfig(testdir): result = testdir.runpytest("--traceconfig") result.stdout.fnmatch_lines(["*active plugins*"]) assert result.ret == ExitCode.NO_TESTS_COLLECTED