Merge remote-tracking branch 'upstream/master' into mm
Conflicts: * src/_pytest/_code/code.py * src/_pytest/main.py * testing/python/metafunc.py * testing/test_parseopt.py * testing/test_pytester.py
This commit is contained in:
@@ -286,7 +286,7 @@ class TestFunction:
|
||||
|
||||
return pytest.Function.from_parent(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
|
||||
|
||||
@@ -1716,138 +1716,6 @@ class TestAutouseDiscovery:
|
||||
reprec.assertoutcome(passed=3)
|
||||
|
||||
|
||||
class TestMultiLevelAutouseAndParameterization:
|
||||
def test_setup_and_teardown_order(self, testdir):
|
||||
"""Tests that parameterized fixtures effect subsequent fixtures. (#6436)
|
||||
|
||||
If a fixture uses a parameterized fixture, or, for any other reason, is executed
|
||||
after the parameterized fixture in the fixture stack, then it should be affected
|
||||
by the parameterization, and as a result, should be torn down before the
|
||||
parameterized fixture, every time the parameterized fixture is torn down. This
|
||||
should be the case even if autouse is involved and/or the linear order of
|
||||
fixture execution isn't deterministic. In other words, before any fixture can be
|
||||
torn down, every fixture that was executed after it must also be torn down.
|
||||
"""
|
||||
testdir.makepyfile(
|
||||
test_auto="""
|
||||
import pytest
|
||||
def f(param):
|
||||
return param
|
||||
@pytest.fixture(scope="session", autouse=True)
|
||||
def s_fix(request):
|
||||
yield
|
||||
@pytest.fixture(scope="package", params=["p1", "p2"], ids=f, autouse=True)
|
||||
def p_fix(request):
|
||||
yield
|
||||
@pytest.fixture(scope="module", params=["m1", "m2"], ids=f, autouse=True)
|
||||
def m_fix(request):
|
||||
yield
|
||||
@pytest.fixture(scope="class", autouse=True)
|
||||
def another_c_fix(m_fix):
|
||||
yield
|
||||
@pytest.fixture(scope="class")
|
||||
def c_fix():
|
||||
yield
|
||||
@pytest.fixture(scope="function", params=["f1", "f2"], ids=f, autouse=True)
|
||||
def f_fix(request):
|
||||
yield
|
||||
class TestFixtures:
|
||||
def test_a(self, c_fix):
|
||||
pass
|
||||
def test_b(self, c_fix):
|
||||
pass
|
||||
"""
|
||||
)
|
||||
result = testdir.runpytest("--setup-plan")
|
||||
test_fixtures_used = (
|
||||
"(fixtures used: another_c_fix, c_fix, f_fix, m_fix, p_fix, request, s_fix)"
|
||||
)
|
||||
result.stdout.fnmatch_lines(
|
||||
"""
|
||||
SETUP S s_fix
|
||||
SETUP P p_fix[p1]
|
||||
SETUP M m_fix[m1]
|
||||
SETUP C another_c_fix (fixtures used: m_fix)
|
||||
SETUP C c_fix
|
||||
SETUP F f_fix[f1]
|
||||
test_auto.py::TestFixtures::test_a[p1-m1-f1] {0}
|
||||
TEARDOWN F f_fix[f1]
|
||||
SETUP F f_fix[f2]
|
||||
test_auto.py::TestFixtures::test_a[p1-m1-f2] {0}
|
||||
TEARDOWN F f_fix[f2]
|
||||
SETUP F f_fix[f1]
|
||||
test_auto.py::TestFixtures::test_b[p1-m1-f1] {0}
|
||||
TEARDOWN F f_fix[f1]
|
||||
SETUP F f_fix[f2]
|
||||
test_auto.py::TestFixtures::test_b[p1-m1-f2] {0}
|
||||
TEARDOWN F f_fix[f2]
|
||||
TEARDOWN C c_fix
|
||||
TEARDOWN C another_c_fix
|
||||
TEARDOWN M m_fix[m1]
|
||||
SETUP M m_fix[m2]
|
||||
SETUP C another_c_fix (fixtures used: m_fix)
|
||||
SETUP C c_fix
|
||||
SETUP F f_fix[f1]
|
||||
test_auto.py::TestFixtures::test_a[p1-m2-f1] {0}
|
||||
TEARDOWN F f_fix[f1]
|
||||
SETUP F f_fix[f2]
|
||||
test_auto.py::TestFixtures::test_a[p1-m2-f2] {0}
|
||||
TEARDOWN F f_fix[f2]
|
||||
SETUP F f_fix[f1]
|
||||
test_auto.py::TestFixtures::test_b[p1-m2-f1] {0}
|
||||
TEARDOWN F f_fix[f1]
|
||||
SETUP F f_fix[f2]
|
||||
test_auto.py::TestFixtures::test_b[p1-m2-f2] {0}
|
||||
TEARDOWN F f_fix[f2]
|
||||
TEARDOWN C c_fix
|
||||
TEARDOWN C another_c_fix
|
||||
TEARDOWN M m_fix[m2]
|
||||
TEARDOWN P p_fix[p1]
|
||||
SETUP P p_fix[p2]
|
||||
SETUP M m_fix[m1]
|
||||
SETUP C another_c_fix (fixtures used: m_fix)
|
||||
SETUP C c_fix
|
||||
SETUP F f_fix[f1]
|
||||
test_auto.py::TestFixtures::test_a[p2-m1-f1] {0}
|
||||
TEARDOWN F f_fix[f1]
|
||||
SETUP F f_fix[f2]
|
||||
test_auto.py::TestFixtures::test_a[p2-m1-f2] {0}
|
||||
TEARDOWN F f_fix[f2]
|
||||
SETUP F f_fix[f1]
|
||||
test_auto.py::TestFixtures::test_b[p2-m1-f1] {0}
|
||||
TEARDOWN F f_fix[f1]
|
||||
SETUP F f_fix[f2]
|
||||
test_auto.py::TestFixtures::test_b[p2-m1-f2] {0}
|
||||
TEARDOWN F f_fix[f2]
|
||||
TEARDOWN C c_fix
|
||||
TEARDOWN C another_c_fix
|
||||
TEARDOWN M m_fix[m1]
|
||||
SETUP M m_fix[m2]
|
||||
SETUP C another_c_fix (fixtures used: m_fix)
|
||||
SETUP C c_fix
|
||||
SETUP F f_fix[f1]
|
||||
test_auto.py::TestFixtures::test_a[p2-m2-f1] {0}
|
||||
TEARDOWN F f_fix[f1]
|
||||
SETUP F f_fix[f2]
|
||||
test_auto.py::TestFixtures::test_a[p2-m2-f2] {0}
|
||||
TEARDOWN F f_fix[f2]
|
||||
SETUP F f_fix[f1]
|
||||
test_auto.py::TestFixtures::test_b[p2-m2-f1] {0}
|
||||
TEARDOWN F f_fix[f1]
|
||||
SETUP F f_fix[f2]
|
||||
test_auto.py::TestFixtures::test_b[p2-m2-f2] {0}
|
||||
TEARDOWN F f_fix[f2]
|
||||
TEARDOWN C c_fix
|
||||
TEARDOWN C another_c_fix
|
||||
TEARDOWN M m_fix[m2]
|
||||
TEARDOWN P p_fix[p2]
|
||||
TEARDOWN S s_fix
|
||||
""".format(
|
||||
test_fixtures_used
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
class TestAutouseManagement:
|
||||
def test_autouse_conftest_mid_directory(self, testdir):
|
||||
pkgdir = testdir.mkpydir("xyz123")
|
||||
@@ -4238,7 +4106,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 +4121,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
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ class TestMetafunc:
|
||||
definition = DefinitionMock._create(func)
|
||||
return python.Metafunc(definition, fixtureinfo, config)
|
||||
|
||||
def test_no_funcargs(self, testdir):
|
||||
def test_no_funcargs(self):
|
||||
def function():
|
||||
pass
|
||||
|
||||
@@ -96,7 +96,7 @@ class TestMetafunc:
|
||||
):
|
||||
metafunc.parametrize("x", [1, 2, 3], ids=gen())
|
||||
|
||||
def test_parametrize_bad_scope(self, testdir):
|
||||
def test_parametrize_bad_scope(self):
|
||||
def func(x):
|
||||
pass
|
||||
|
||||
@@ -188,7 +188,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
|
||||
|
||||
@@ -712,7 +712,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):
|
||||
|
||||
Reference in New Issue
Block a user