typographic fixes, little simplification
This commit is contained in:
parent
2855a2f6cb
commit
dc4e205876
|
@ -361,7 +361,6 @@ class FixtureMapper:
|
||||||
|
|
||||||
def __init__(self, node, funcargs=True):
|
def __init__(self, node, funcargs=True):
|
||||||
self.node = node
|
self.node = node
|
||||||
self.fm = node.session._fixturemanager
|
|
||||||
self._name2fixtureinfo = {}
|
self._name2fixtureinfo = {}
|
||||||
self.hasfuncargs = funcargs
|
self.hasfuncargs = funcargs
|
||||||
|
|
||||||
|
@ -378,8 +377,9 @@ class FixtureMapper:
|
||||||
initialnames = argnames
|
initialnames = argnames
|
||||||
if usefixtures is not None:
|
if usefixtures is not None:
|
||||||
initialnames = usefixtures.args + initialnames
|
initialnames = usefixtures.args + initialnames
|
||||||
names_closure, arg2fixturedefs = self.fm.getfixtureclosure(
|
fm = self.node.session._fixturemanager
|
||||||
initialnames, self.node)
|
names_closure, arg2fixturedefs = fm.getfixtureclosure(initialnames,
|
||||||
|
self.node)
|
||||||
fixtureinfo = FuncFixtureInfo(argnames, names_closure,
|
fixtureinfo = FuncFixtureInfo(argnames, names_closure,
|
||||||
arg2fixturedefs)
|
arg2fixturedefs)
|
||||||
self._name2fixtureinfo[func] = fixtureinfo
|
self._name2fixtureinfo[func] = fixtureinfo
|
||||||
|
|
|
@ -28,7 +28,7 @@ def test_setup_func_with_setup_decorator():
|
||||||
from _pytest.nose import call_optional
|
from _pytest.nose import call_optional
|
||||||
l = []
|
l = []
|
||||||
class A:
|
class A:
|
||||||
@pytest.fixture( autouse=True)
|
@pytest.fixture(autouse=True)
|
||||||
def f(self):
|
def f(self):
|
||||||
l.append(1)
|
l.append(1)
|
||||||
call_optional(A(), "f")
|
call_optional(A(), "f")
|
||||||
|
|
|
@ -456,24 +456,6 @@ def test_setup_only_available_in_subdir(testdir):
|
||||||
"*2 passed*"
|
"*2 passed*"
|
||||||
])
|
])
|
||||||
|
|
||||||
def test_generate_tests_only_done_in_subdir(testdir):
|
|
||||||
sub1 = testdir.mkpydir("sub1")
|
|
||||||
sub2 = testdir.mkpydir("sub2")
|
|
||||||
sub1.join("conftest.py").write(py.code.Source("""
|
|
||||||
def pytest_generate_tests(metafunc):
|
|
||||||
assert metafunc.function.__name__ == "test_1"
|
|
||||||
"""))
|
|
||||||
sub2.join("conftest.py").write(py.code.Source("""
|
|
||||||
def pytest_generate_tests(metafunc):
|
|
||||||
assert metafunc.function.__name__ == "test_2"
|
|
||||||
"""))
|
|
||||||
sub1.join("test_in_sub1.py").write("def test_1(): pass")
|
|
||||||
sub2.join("test_in_sub2.py").write("def test_2(): pass")
|
|
||||||
result = testdir.runpytest("-v", "-s", sub1, sub2, sub1)
|
|
||||||
result.stdout.fnmatch_lines([
|
|
||||||
"*3 passed*"
|
|
||||||
])
|
|
||||||
|
|
||||||
def test_modulecol_roundtrip(testdir):
|
def test_modulecol_roundtrip(testdir):
|
||||||
modcol = testdir.getmodulecol("pass", withinit=True)
|
modcol = testdir.getmodulecol("pass", withinit=True)
|
||||||
trail = modcol.nodeid
|
trail = modcol.nodeid
|
||||||
|
@ -1404,7 +1386,7 @@ class TestMetafuncFunctional:
|
||||||
reprec = testdir.inline_run()
|
reprec = testdir.inline_run()
|
||||||
reprec.assertoutcome(passed=5)
|
reprec.assertoutcome(passed=5)
|
||||||
|
|
||||||
def test_usemarkers_seen_in_generate_tests(self, testdir):
|
def test_usefixtures_seen_in_generate_tests(self, testdir):
|
||||||
testdir.makepyfile("""
|
testdir.makepyfile("""
|
||||||
import pytest
|
import pytest
|
||||||
def pytest_generate_tests(metafunc):
|
def pytest_generate_tests(metafunc):
|
||||||
|
@ -1418,6 +1400,25 @@ class TestMetafuncFunctional:
|
||||||
reprec = testdir.inline_run()
|
reprec = testdir.inline_run()
|
||||||
reprec.assertoutcome(passed=1)
|
reprec.assertoutcome(passed=1)
|
||||||
|
|
||||||
|
def test_generate_tests_only_done_in_subdir(self, testdir):
|
||||||
|
sub1 = testdir.mkpydir("sub1")
|
||||||
|
sub2 = testdir.mkpydir("sub2")
|
||||||
|
sub1.join("conftest.py").write(py.code.Source("""
|
||||||
|
def pytest_generate_tests(metafunc):
|
||||||
|
assert metafunc.function.__name__ == "test_1"
|
||||||
|
"""))
|
||||||
|
sub2.join("conftest.py").write(py.code.Source("""
|
||||||
|
def pytest_generate_tests(metafunc):
|
||||||
|
assert metafunc.function.__name__ == "test_2"
|
||||||
|
"""))
|
||||||
|
sub1.join("test_in_sub1.py").write("def test_1(): pass")
|
||||||
|
sub2.join("test_in_sub2.py").write("def test_2(): pass")
|
||||||
|
result = testdir.runpytest("-v", "-s", sub1, sub2, sub1)
|
||||||
|
result.stdout.fnmatch_lines([
|
||||||
|
"*3 passed*"
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
def test_conftest_funcargs_only_available_in_subdir(testdir):
|
def test_conftest_funcargs_only_available_in_subdir(testdir):
|
||||||
sub1 = testdir.mkpydir("sub1")
|
sub1 = testdir.mkpydir("sub1")
|
||||||
sub2 = testdir.mkpydir("sub2")
|
sub2 = testdir.mkpydir("sub2")
|
||||||
|
@ -1464,6 +1465,7 @@ def test_funcarg_non_pycollectobj(testdir): # rough jstests usage
|
||||||
assert clscol.funcargs['arg1'] == 42
|
assert clscol.funcargs['arg1'] == 42
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def test_funcarg_lookup_error(testdir):
|
def test_funcarg_lookup_error(testdir):
|
||||||
p = testdir.makepyfile("""
|
p = testdir.makepyfile("""
|
||||||
def test_lookup_error(unknown):
|
def test_lookup_error(unknown):
|
||||||
|
@ -2000,18 +2002,18 @@ class TestFixtureManager:
|
||||||
reprec = testdir.inline_run("-s")
|
reprec = testdir.inline_run("-s")
|
||||||
reprec.assertoutcome(passed=1)
|
reprec.assertoutcome(passed=1)
|
||||||
|
|
||||||
class TestSetupDiscovery:
|
class TestAutouseDiscovery:
|
||||||
def pytest_funcarg__testdir(self, testdir):
|
def pytest_funcarg__testdir(self, testdir):
|
||||||
testdir.makeconftest("""
|
testdir.makeconftest("""
|
||||||
import pytest
|
import pytest
|
||||||
@pytest.fixture( autouse=True)
|
@pytest.fixture(autouse=True)
|
||||||
def perfunction(request, tmpdir):
|
def perfunction(request, tmpdir):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@pytest.fixture()
|
@pytest.fixture()
|
||||||
def arg1(tmpdir):
|
def arg1(tmpdir):
|
||||||
pass
|
pass
|
||||||
@pytest.fixture( autouse=True)
|
@pytest.fixture(autouse=True)
|
||||||
def perfunction2(arg1):
|
def perfunction2(arg1):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -2153,7 +2155,7 @@ class TestSetupDiscovery:
|
||||||
reprec = testdir.inline_run()
|
reprec = testdir.inline_run()
|
||||||
reprec.assertoutcome(passed=3)
|
reprec.assertoutcome(passed=3)
|
||||||
|
|
||||||
class TestSetupManagement:
|
class TestAutouseManagement:
|
||||||
def test_funcarg_and_setup(self, testdir):
|
def test_funcarg_and_setup(self, testdir):
|
||||||
testdir.makepyfile("""
|
testdir.makepyfile("""
|
||||||
import pytest
|
import pytest
|
||||||
|
@ -2179,7 +2181,7 @@ class TestSetupManagement:
|
||||||
reprec = testdir.inline_run()
|
reprec = testdir.inline_run()
|
||||||
reprec.assertoutcome(passed=2)
|
reprec.assertoutcome(passed=2)
|
||||||
|
|
||||||
def test_setup_uses_parametrized_resource(self, testdir):
|
def test_uses_parametrized_resource(self, testdir):
|
||||||
testdir.makepyfile("""
|
testdir.makepyfile("""
|
||||||
import pytest
|
import pytest
|
||||||
l = []
|
l = []
|
||||||
|
@ -2187,7 +2189,7 @@ class TestSetupManagement:
|
||||||
def arg(request):
|
def arg(request):
|
||||||
return request.param
|
return request.param
|
||||||
|
|
||||||
@pytest.fixture( autouse=True)
|
@pytest.fixture(autouse=True)
|
||||||
def something(arg):
|
def something(arg):
|
||||||
l.append(arg)
|
l.append(arg)
|
||||||
|
|
||||||
|
@ -2203,7 +2205,7 @@ class TestSetupManagement:
|
||||||
reprec = testdir.inline_run("-s")
|
reprec = testdir.inline_run("-s")
|
||||||
reprec.assertoutcome(passed=2)
|
reprec.assertoutcome(passed=2)
|
||||||
|
|
||||||
def test_session_parametrized_function_setup(self, testdir):
|
def test_session_parametrized_function(self, testdir):
|
||||||
testdir.makepyfile("""
|
testdir.makepyfile("""
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
@ -2265,7 +2267,7 @@ class TestSetupManagement:
|
||||||
l = config._conftest.getconftestmodules(p)[0].l
|
l = config._conftest.getconftestmodules(p)[0].l
|
||||||
assert l == ["fin_a1", "fin_a2", "fin_b1", "fin_b2"] * 2
|
assert l == ["fin_a1", "fin_a2", "fin_b1", "fin_b2"] * 2
|
||||||
|
|
||||||
def test_setup_scope_ordering(self, testdir):
|
def test_scope_ordering(self, testdir):
|
||||||
testdir.makepyfile("""
|
testdir.makepyfile("""
|
||||||
import pytest
|
import pytest
|
||||||
l = []
|
l = []
|
||||||
|
@ -2799,7 +2801,7 @@ class TestErrors:
|
||||||
def test_setupfunc_missing_funcarg(self, testdir):
|
def test_setupfunc_missing_funcarg(self, testdir):
|
||||||
testdir.makepyfile("""
|
testdir.makepyfile("""
|
||||||
import pytest
|
import pytest
|
||||||
@pytest.fixture( autouse=True)
|
@pytest.fixture(autouse=True)
|
||||||
def gen(qwe123):
|
def gen(qwe123):
|
||||||
return 1
|
return 1
|
||||||
def test_something():
|
def test_something():
|
||||||
|
@ -2834,7 +2836,7 @@ class TestTestContextVarious:
|
||||||
def arg(request):
|
def arg(request):
|
||||||
return request.param
|
return request.param
|
||||||
|
|
||||||
@pytest.fixture( autouse=True)
|
@pytest.fixture(autouse=True)
|
||||||
def mysetup(request, arg):
|
def mysetup(request, arg):
|
||||||
assert not hasattr(request, "param")
|
assert not hasattr(request, "param")
|
||||||
def test_1(arg):
|
def test_1(arg):
|
||||||
|
@ -2850,7 +2852,7 @@ def test_setupdecorator_and_xunit(testdir):
|
||||||
@pytest.fixture(scope='module', autouse=True)
|
@pytest.fixture(scope='module', autouse=True)
|
||||||
def setup_module():
|
def setup_module():
|
||||||
l.append("module")
|
l.append("module")
|
||||||
@pytest.fixture( autouse=True)
|
@pytest.fixture(autouse=True)
|
||||||
def setup_function():
|
def setup_function():
|
||||||
l.append("function")
|
l.append("function")
|
||||||
|
|
||||||
|
@ -2861,7 +2863,7 @@ def test_setupdecorator_and_xunit(testdir):
|
||||||
@pytest.fixture(scope="class", autouse=True)
|
@pytest.fixture(scope="class", autouse=True)
|
||||||
def setup_class(self):
|
def setup_class(self):
|
||||||
l.append("class")
|
l.append("class")
|
||||||
@pytest.fixture( autouse=True)
|
@pytest.fixture(autouse=True)
|
||||||
def setup_method(self):
|
def setup_method(self):
|
||||||
l.append("method")
|
l.append("method")
|
||||||
def test_method(self):
|
def test_method(self):
|
||||||
|
@ -2880,7 +2882,7 @@ def test_setup_funcarg_order(testdir):
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
l = []
|
l = []
|
||||||
@pytest.fixture( autouse=True)
|
@pytest.fixture(autouse=True)
|
||||||
def fix1():
|
def fix1():
|
||||||
l.append(1)
|
l.append(1)
|
||||||
@pytest.fixture()
|
@pytest.fixture()
|
||||||
|
@ -2902,7 +2904,7 @@ def test_request_fixturenames(testdir):
|
||||||
@pytest.fixture()
|
@pytest.fixture()
|
||||||
def farg(arg1):
|
def farg(arg1):
|
||||||
pass
|
pass
|
||||||
@pytest.fixture( autouse=True)
|
@pytest.fixture(autouse=True)
|
||||||
def sarg(tmpdir):
|
def sarg(tmpdir):
|
||||||
pass
|
pass
|
||||||
def test_function(request, farg):
|
def test_function(request, farg):
|
||||||
|
|
Loading…
Reference in New Issue