Merge pull request #6477 from blueyed/tests-cleanup-unused-fixtures
tests: cleanup unused fixtures
This commit is contained in:
commit
f0fdafeddc
|
@ -606,7 +606,7 @@ class TestInvocationVariants:
|
|||
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 @@ class TestInvocationVariants:
|
|||
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")
|
||||
|
|
|
@ -17,7 +17,7 @@ if sys.gettrace():
|
|||
|
||||
|
||||
@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
|
||||
|
|
|
@ -626,7 +626,7 @@ def test_log_cli_ini_level(testdir):
|
|||
"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.
|
||||
"""
|
||||
|
|
|
@ -286,7 +286,7 @@ class TestFunction:
|
|||
|
||||
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 @@ class TestFunction:
|
|||
)
|
||||
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 @@ class TestFunction:
|
|||
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 @@ class TestTracebackCutting:
|
|||
|
||||
|
||||
class TestReportInfo:
|
||||
def test_itemreport_reportinfo(self, testdir, linecomp):
|
||||
def test_itemreport_reportinfo(self, testdir):
|
||||
testdir.makeconftest(
|
||||
"""
|
||||
import pytest
|
||||
|
|
|
@ -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 test_fixture_duplicated_arguments(testdir):
|
|||
)
|
||||
|
||||
|
||||
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
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ class TestMetafunc:
|
|||
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 @@ class TestMetafunc:
|
|||
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 @@ class TestMetafunc:
|
|||
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 @@ class TestMetafunc:
|
|||
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):
|
||||
|
|
|
@ -1299,7 +1299,7 @@ def test_AssertionError_message(testdir):
|
|||
)
|
||||
|
||||
|
||||
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_assert_indirect_tuple_no_warning(testdir):
|
|||
assert "WR1" not in output
|
||||
|
||||
|
||||
def test_assert_with_unicode(monkeypatch, testdir):
|
||||
def test_assert_with_unicode(testdir):
|
||||
testdir.makepyfile(
|
||||
"""\
|
||||
def test_unicode():
|
||||
|
|
|
@ -937,7 +937,7 @@ class TestFDCapture:
|
|||
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 @@ class TestFDCapture:
|
|||
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()
|
||||
|
|
|
@ -243,7 +243,7 @@ class TestCollectPluginHookRelay:
|
|||
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 @@ class TestCollectPluginHookRelay:
|
|||
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_collect_symlink_out_of_tree(testdir):
|
|||
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']")
|
||||
|
|
|
@ -357,7 +357,7 @@ def test_conftest_import_order(testdir, monkeypatch):
|
|||
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("")
|
||||
|
|
|
@ -82,7 +82,7 @@ def test_timeout(testdir, enabled):
|
|||
|
||||
|
||||
@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).
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -41,7 +41,7 @@ class TestMark:
|
|||
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.
|
||||
"""
|
||||
|
|
|
@ -254,14 +254,14 @@ class TestParser:
|
|||
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(
|
||||
|
|
|
@ -463,7 +463,7 @@ class TestPDB:
|
|||
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 @@ class TestPDB:
|
|||
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 @@ class TestPDB:
|
|||
]
|
||||
)
|
||||
|
||||
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__",
|
||||
|
|
|
@ -71,7 +71,7 @@ class TestPytestPluginInteractions:
|
|||
values = []
|
||||
|
||||
class A:
|
||||
def pytest_configure(self, config):
|
||||
def pytest_configure(self):
|
||||
values.append(self)
|
||||
|
||||
config.pluginmanager.register(A())
|
||||
|
|
|
@ -621,7 +621,7 @@ class TestTerminalFunctional:
|
|||
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 @@ class TestTerminalFunctional:
|
|||
"""
|
||||
)
|
||||
|
||||
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_tbstyle_short(testdir):
|
|||
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
|
||||
|
|
Loading…
Reference in New Issue