Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: cleanup unused fixtures #6477

Merged
merged 1 commit into from Jan 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions testing/acceptance_test.py
Expand Up @@ -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'"
):
Expand All @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion testing/conftest.py
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion testing/logging/test_reporting.py
Expand Up @@ -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.
"""
Expand Down
10 changes: 5 additions & 5 deletions testing/python/collect.py
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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())
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions testing/python/fixtures.py
Expand Up @@ -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:

Expand All @@ -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

Expand Down
8 changes: 4 additions & 4 deletions testing/python/metafunc.py
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions testing/test_assertion.py
Expand Up @@ -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():
Expand Down Expand Up @@ -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():
Expand Down
4 changes: 2 additions & 2 deletions testing/test_capture.py
Expand Up @@ -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()
Expand All @@ -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()
Expand Down
6 changes: 3 additions & 3 deletions testing/test_collection.py
Expand Up @@ -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)
Expand All @@ -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")
Expand Down Expand Up @@ -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']")
Expand Down
2 changes: 1 addition & 1 deletion testing/test_conftest.py
Expand Up @@ -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("")
Expand Down
2 changes: 1 addition & 1 deletion testing/test_faulthandler.py
Expand Up @@ -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).
Expand Down
2 changes: 1 addition & 1 deletion testing/test_helpconfig.py
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion testing/test_mark.py
Expand Up @@ -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.
"""
Expand Down
4 changes: 2 additions & 2 deletions testing/test_parseopt.py
Expand Up @@ -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(
Expand Down
6 changes: 3 additions & 3 deletions testing/test_pdb.py
Expand Up @@ -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():
Expand All @@ -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():
Expand Down Expand Up @@ -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__",
Expand Down
2 changes: 1 addition & 1 deletion testing/test_pluginmanager.py
Expand Up @@ -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())
Expand Down
6 changes: 3 additions & 3 deletions testing/test_terminal.py
Expand Up @@ -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()

Expand Down Expand Up @@ -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"
)
Expand Down Expand Up @@ -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
Expand Down