Skip to content

Commit f0fdafe

Browse files
authored
Merge pull request #6477 from blueyed/tests-cleanup-unused-fixtures
tests: cleanup unused fixtures
2 parents d36c712 + 5049e25 commit f0fdafe

17 files changed

+35
-35
lines changed

testing/acceptance_test.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,7 @@ def test_python_pytest_package(self, testdir):
606606
def test_equivalence_pytest_pytest(self):
607607
assert pytest.main == py.test.cmdline.main
608608

609-
def test_invoke_with_invalid_type(self, capsys):
609+
def test_invoke_with_invalid_type(self):
610610
with pytest.raises(
611611
TypeError, match="expected to be a list or tuple of strings, got: '-h'"
612612
):
@@ -617,7 +617,7 @@ def test_invoke_with_path(self, tmpdir, capsys):
617617
assert retcode == ExitCode.NO_TESTS_COLLECTED
618618
out, err = capsys.readouterr()
619619

620-
def test_invoke_plugin_api(self, testdir, capsys):
620+
def test_invoke_plugin_api(self, capsys):
621621
class MyPlugin:
622622
def pytest_addoption(self, parser):
623623
parser.addoption("--myopt")

testing/conftest.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def restore_tracing():
1717

1818

1919
@pytest.hookimpl(hookwrapper=True, tryfirst=True)
20-
def pytest_collection_modifyitems(config, items):
20+
def pytest_collection_modifyitems(items):
2121
"""Prefer faster tests.
2222
2323
Use a hookwrapper to do this in the beginning, so e.g. --ff still works

testing/logging/test_reporting.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,7 @@ def test_log_cli(request):
626626
"cli_args",
627627
["", "--log-level=WARNING", "--log-file-level=WARNING", "--log-cli-level=WARNING"],
628628
)
629-
def test_log_cli_auto_enable(testdir, request, cli_args):
629+
def test_log_cli_auto_enable(testdir, cli_args):
630630
"""Check that live logs are enabled if --log-level or --log-cli-level is passed on the CLI.
631631
It should not be auto enabled if the same configs are set on the INI file.
632632
"""

testing/python/collect.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ def make_function(testdir, **kwargs):
286286

287287
return pytest.Function(config=config, parent=session, **kwargs)
288288

289-
def test_function_equality(self, testdir, tmpdir):
289+
def test_function_equality(self, testdir):
290290
def func1():
291291
pass
292292

@@ -492,7 +492,7 @@ def test_function(arg):
492492
)
493493
assert "foo" in keywords[1] and "bar" in keywords[1] and "baz" in keywords[1]
494494

495-
def test_function_equality_with_callspec(self, testdir, tmpdir):
495+
def test_function_equality_with_callspec(self, testdir):
496496
items = testdir.getitems(
497497
"""
498498
import pytest
@@ -509,11 +509,11 @@ def test_pyfunc_call(self, testdir):
509509
config = item.config
510510

511511
class MyPlugin1:
512-
def pytest_pyfunc_call(self, pyfuncitem):
512+
def pytest_pyfunc_call(self):
513513
raise ValueError
514514

515515
class MyPlugin2:
516-
def pytest_pyfunc_call(self, pyfuncitem):
516+
def pytest_pyfunc_call(self):
517517
return True
518518

519519
config.pluginmanager.register(MyPlugin1())
@@ -1015,7 +1015,7 @@ def foo():
10151015

10161016

10171017
class TestReportInfo:
1018-
def test_itemreport_reportinfo(self, testdir, linecomp):
1018+
def test_itemreport_reportinfo(self, testdir):
10191019
testdir.makeconftest(
10201020
"""
10211021
import pytest

testing/python/fixtures.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -4238,7 +4238,7 @@ def test_fixture_named_request(testdir):
42384238
)
42394239

42404240

4241-
def test_fixture_duplicated_arguments(testdir):
4241+
def test_fixture_duplicated_arguments():
42424242
"""Raise error if there are positional and keyword arguments for the same parameter (#1682)."""
42434243
with pytest.raises(TypeError) as excinfo:
42444244

@@ -4253,7 +4253,7 @@ def arg(arg):
42534253
)
42544254

42554255

4256-
def test_fixture_with_positionals(testdir):
4256+
def test_fixture_with_positionals():
42574257
"""Raise warning, but the positionals should still works (#1682)."""
42584258
from _pytest.deprecated import FIXTURE_POSITIONAL_ARGUMENTS
42594259

testing/python/metafunc.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class DefinitionMock(python.FunctionDefinition):
3131
definition = DefinitionMock(func)
3232
return python.Metafunc(definition, fixtureinfo, config)
3333

34-
def test_no_funcargs(self, testdir):
34+
def test_no_funcargs(self):
3535
def function():
3636
pass
3737

@@ -61,7 +61,7 @@ def func(x, y):
6161
pytest.raises(ValueError, lambda: metafunc.parametrize("y", [5, 6]))
6262
pytest.raises(ValueError, lambda: metafunc.parametrize("y", [5, 6]))
6363

64-
def test_parametrize_bad_scope(self, testdir):
64+
def test_parametrize_bad_scope(self):
6565
def func(x):
6666
pass
6767

@@ -153,7 +153,7 @@ def func(x):
153153
ids = [x.id for x in metafunc._calls]
154154
assert ids == ["basic", "advanced"]
155155

156-
def test_parametrize_with_wrong_number_of_ids(self, testdir):
156+
def test_parametrize_with_wrong_number_of_ids(self):
157157
def func(x, y):
158158
pass
159159

@@ -652,7 +652,7 @@ def test_simple(x,y):
652652
result = testdir.runpytest("-v")
653653
result.stdout.fnmatch_lines(["*test_simple*a-b*", "*1 passed*"])
654654

655-
def test_parametrize_indirect_list_error(self, testdir):
655+
def test_parametrize_indirect_list_error(self):
656656
"""#714"""
657657

658658
def func(x, y):

testing/test_assertion.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1299,7 +1299,7 @@ def test_hello():
12991299
)
13001300

13011301

1302-
def test_diff_newline_at_end(monkeypatch, testdir):
1302+
def test_diff_newline_at_end(testdir):
13031303
testdir.makepyfile(
13041304
r"""
13051305
def test_diff():
@@ -1354,7 +1354,7 @@ def test_tuple():
13541354
assert "WR1" not in output
13551355

13561356

1357-
def test_assert_with_unicode(monkeypatch, testdir):
1357+
def test_assert_with_unicode(testdir):
13581358
testdir.makepyfile(
13591359
"""\
13601360
def test_unicode():

testing/test_capture.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -937,7 +937,7 @@ def test_stderr(self):
937937
cap.done()
938938
assert s == "hello\n"
939939

940-
def test_stdin(self, tmpfile):
940+
def test_stdin(self):
941941
cap = capture.FDCapture(0)
942942
cap.start()
943943
x = os.read(0, 100).strip()
@@ -958,7 +958,7 @@ def test_writeorg(self, tmpfile):
958958
stmp = stmp_file.read()
959959
assert stmp == data2
960960

961-
def test_simple_resume_suspend(self, tmpfile):
961+
def test_simple_resume_suspend(self):
962962
with saved_fd(1):
963963
cap = capture.FDCapture(1)
964964
cap.start()

testing/test_collection.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ def test_pytest_collect_file(self, testdir):
243243
wascalled = []
244244

245245
class Plugin:
246-
def pytest_collect_file(self, path, parent):
246+
def pytest_collect_file(self, path):
247247
if not path.basename.startswith("."):
248248
# Ignore hidden files, e.g. .testmondata.
249249
wascalled.append(path)
@@ -257,7 +257,7 @@ def test_pytest_collect_directory(self, testdir):
257257
wascalled = []
258258

259259
class Plugin:
260-
def pytest_collect_directory(self, path, parent):
260+
def pytest_collect_directory(self, path):
261261
wascalled.append(path.basename)
262262

263263
testdir.mkdir("hello")
@@ -1173,7 +1173,7 @@ def test_nodeid(request):
11731173
assert result.ret == 0
11741174

11751175

1176-
def test_collectignore_via_conftest(testdir, monkeypatch):
1176+
def test_collectignore_via_conftest(testdir):
11771177
"""collect_ignore in parent conftest skips importing child (issue #4592)."""
11781178
tests = testdir.mkpydir("tests")
11791179
tests.ensure("conftest.py").write("collect_ignore = ['ignore_me']")

testing/test_conftest.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ def impct(p):
357357
assert conftest._getconftestmodules(sub) == [ct1, ct2]
358358

359359

360-
def test_fixture_dependency(testdir, monkeypatch):
360+
def test_fixture_dependency(testdir):
361361
ct1 = testdir.makeconftest("")
362362
ct1 = testdir.makepyfile("__init__.py")
363363
ct1.write("")

testing/test_faulthandler.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def test_timeout():
8282

8383

8484
@pytest.mark.parametrize("hook_name", ["pytest_enter_pdb", "pytest_exception_interact"])
85-
def test_cancel_timeout_on_hook(monkeypatch, pytestconfig, hook_name):
85+
def test_cancel_timeout_on_hook(monkeypatch, hook_name):
8686
"""Make sure that we are cancelling any scheduled traceback dumping due
8787
to timeout before entering pdb (pytest-dev/pytest-faulthandler#12) or any other interactive
8888
exception (pytest-dev/pytest-faulthandler#14).

testing/test_helpconfig.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def test_traceconfig(testdir):
5757
result.stdout.fnmatch_lines(["*using*pytest*py*", "*active plugins*"])
5858

5959

60-
def test_debug(testdir, monkeypatch):
60+
def test_debug(testdir):
6161
result = testdir.runpytest_subprocess("--debug")
6262
assert result.ret == ExitCode.NO_TESTS_COLLECTED
6363
p = testdir.tmpdir.join("pytestdebug.log")

testing/test_mark.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def test_pytest_mark_name_starts_with_underscore(self):
4141
mark._some_name
4242

4343

44-
def test_marked_class_run_twice(testdir, request):
44+
def test_marked_class_run_twice(testdir):
4545
"""Test fails file is run twice that contains marked class.
4646
See issue#683.
4747
"""

testing/test_parseopt.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -254,14 +254,14 @@ def test_drop_short_3(self, parser):
254254
assert args.func_arg is False
255255
assert args.file_or_dir == ["abcd"]
256256

257-
def test_drop_short_help0(self, parser, capsys):
257+
def test_drop_short_help0(self, parser):
258258
parser.addoption("--func-args", "--doit", help="foo", action="store_true")
259259
parser.parse([])
260260
help = parser.optparser.format_help()
261261
assert "--func-args, --doit foo" in help
262262

263263
# testing would be more helpful with all help generated
264-
def test_drop_short_help1(self, parser, capsys):
264+
def test_drop_short_help1(self, parser):
265265
group = parser.getgroup("general")
266266
group.addoption("--doit", "--func-args", action="store_true", help="foo")
267267
group._addoption(

testing/test_pdb.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ def test_2():
463463
child.read()
464464
self.flush(child)
465465

466-
def test_pdb_interaction_doctest(self, testdir, monkeypatch):
466+
def test_pdb_interaction_doctest(self, testdir):
467467
p1 = testdir.makepyfile(
468468
"""
469469
def function_1():
@@ -489,7 +489,7 @@ def function_1():
489489
assert "1 failed" in rest
490490
self.flush(child)
491491

492-
def test_doctest_set_trace_quit(self, testdir, monkeypatch):
492+
def test_doctest_set_trace_quit(self, testdir):
493493
p1 = testdir.makepyfile(
494494
"""
495495
def function_1():
@@ -833,7 +833,7 @@ def test_pdb_custom_cls_invalid(self, testdir):
833833
]
834834
)
835835

836-
def test_pdb_validate_usepdb_cls(self, testdir):
836+
def test_pdb_validate_usepdb_cls(self):
837837
assert _validate_usepdb_cls("os.path:dirname.__name__") == (
838838
"os.path",
839839
"dirname.__name__",

testing/test_pluginmanager.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def test_configure(self, testdir):
7171
values = []
7272

7373
class A:
74-
def pytest_configure(self, config):
74+
def pytest_configure(self):
7575
values.append(self)
7676

7777
config.pluginmanager.register(A())

testing/test_terminal.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,7 @@ def test_passes():
621621
if request.config.pluginmanager.list_plugin_distinfo():
622622
result.stdout.fnmatch_lines(["plugins: *"])
623623

624-
def test_header(self, testdir, request):
624+
def test_header(self, testdir):
625625
testdir.tmpdir.join("tests").ensure_dir()
626626
testdir.tmpdir.join("gui").ensure_dir()
627627

@@ -687,7 +687,7 @@ def check(x):
687687
"""
688688
)
689689

690-
def test_verbose_reporting(self, verbose_testfile, testdir, pytestconfig):
690+
def test_verbose_reporting(self, verbose_testfile, testdir):
691691
result = testdir.runpytest(
692692
verbose_testfile, "-v", "-Walways::pytest.PytestWarning"
693693
)
@@ -943,7 +943,7 @@ def test_opt(arg):
943943
assert "assert x" in s
944944

945945

946-
def test_traceconfig(testdir, monkeypatch):
946+
def test_traceconfig(testdir):
947947
result = testdir.runpytest("--traceconfig")
948948
result.stdout.fnmatch_lines(["*active plugins*"])
949949
assert result.ret == ExitCode.NO_TESTS_COLLECTED

0 commit comments

Comments
 (0)