streamline pytester API majorly:
- integrate conftest into pytester plugin - introduce runpytest() to either call runpytest_inline (default) or runpytest_subprocess (python -m pytest) - move testdir.inline_runsource1 to pdb tests - strike some unneccessary methods. - a new section "writing plugins" and some better pytester docs --HG-- branch : testrefactor
This commit is contained in:
@@ -15,7 +15,7 @@ class TestModule:
|
||||
p.pyimport()
|
||||
del py.std.sys.modules['test_whatever']
|
||||
b.ensure("test_whatever.py")
|
||||
result = testdir.inline_runpytest()
|
||||
result = testdir.runpytest_inprocess()
|
||||
result.stdout.fnmatch_lines([
|
||||
"*import*mismatch*",
|
||||
"*imported*test_whatever*",
|
||||
@@ -59,7 +59,7 @@ class TestClass:
|
||||
def __init__(self):
|
||||
pass
|
||||
""")
|
||||
result = testdir.inline_runpytest("-rw")
|
||||
result = testdir.runpytest_inprocess("-rw")
|
||||
result.stdout.fnmatch_lines_random("""
|
||||
WC1*test_class_with_init_warning.py*__init__*
|
||||
""")
|
||||
@@ -69,7 +69,7 @@ class TestClass:
|
||||
class test(object):
|
||||
pass
|
||||
""")
|
||||
result = testdir.inline_runpytest()
|
||||
result = testdir.runpytest_inprocess()
|
||||
result.stdout.fnmatch_lines([
|
||||
"*collected 0*",
|
||||
])
|
||||
@@ -86,7 +86,7 @@ class TestClass:
|
||||
def teardown_class(cls):
|
||||
pass
|
||||
""")
|
||||
result = testdir.inline_runpytest()
|
||||
result = testdir.runpytest_inprocess()
|
||||
result.stdout.fnmatch_lines([
|
||||
"*1 passed*",
|
||||
])
|
||||
@@ -534,7 +534,7 @@ class TestConftestCustomization:
|
||||
""")
|
||||
testdir.makepyfile("def test_some(): pass")
|
||||
testdir.makepyfile(test_xyz="def test_func(): pass")
|
||||
result = testdir.inline_runpytest("--collect-only")
|
||||
result = testdir.runpytest_inprocess("--collect-only")
|
||||
result.stdout.fnmatch_lines([
|
||||
"*<Module*test_pytest*",
|
||||
"*<MyModule*xyz*",
|
||||
@@ -590,7 +590,7 @@ class TestConftestCustomization:
|
||||
return MyFunction(name, collector)
|
||||
""")
|
||||
testdir.makepyfile("def some(): pass")
|
||||
result = testdir.inline_runpytest("--collect-only")
|
||||
result = testdir.runpytest_inprocess("--collect-only")
|
||||
result.stdout.fnmatch_lines([
|
||||
"*MyFunction*some*",
|
||||
])
|
||||
@@ -648,7 +648,7 @@ class TestTracebackCutting:
|
||||
raise ValueError("xyz")
|
||||
""")
|
||||
p = testdir.makepyfile("def test(hello): pass")
|
||||
result = testdir.inline_runpytest(p)
|
||||
result = testdir.runpytest_inprocess(p)
|
||||
assert result.ret != 0
|
||||
out = result.stdout.str()
|
||||
assert out.find("xyz") != -1
|
||||
@@ -656,7 +656,7 @@ class TestTracebackCutting:
|
||||
numentries = out.count("_ _ _") # separator for traceback entries
|
||||
assert numentries == 0
|
||||
|
||||
result = testdir.inline_runpytest("--fulltrace", p)
|
||||
result = testdir.runpytest_inprocess("--fulltrace", p)
|
||||
out = result.stdout.str()
|
||||
assert out.find("conftest.py:2: ValueError") != -1
|
||||
numentries = out.count("_ _ _ _") # separator for traceback entries
|
||||
@@ -669,7 +669,7 @@ class TestTracebackCutting:
|
||||
x = 17
|
||||
asd
|
||||
""")
|
||||
result = testdir.inline_runpytest()
|
||||
result = testdir.runpytest_inprocess()
|
||||
assert result.ret != 0
|
||||
out = result.stdout.str()
|
||||
assert "x = 1" not in out
|
||||
@@ -678,7 +678,7 @@ class TestTracebackCutting:
|
||||
" *asd*",
|
||||
"E*NameError*",
|
||||
])
|
||||
result = testdir.inline_runpytest("--fulltrace")
|
||||
result = testdir.runpytest_inprocess("--fulltrace")
|
||||
out = result.stdout.str()
|
||||
assert "x = 1" in out
|
||||
assert "x = 2" in out
|
||||
@@ -769,7 +769,7 @@ def test_customized_python_discovery(testdir):
|
||||
""")
|
||||
p2 = p.new(basename=p.basename.replace("test", "check"))
|
||||
p.move(p2)
|
||||
result = testdir.inline_runpytest("--collect-only", "-s")
|
||||
result = testdir.runpytest_inprocess("--collect-only", "-s")
|
||||
result.stdout.fnmatch_lines([
|
||||
"*check_customized*",
|
||||
"*check_simple*",
|
||||
@@ -777,7 +777,7 @@ def test_customized_python_discovery(testdir):
|
||||
"*check_meth*",
|
||||
])
|
||||
|
||||
result = testdir.inline_runpytest()
|
||||
result = testdir.runpytest_inprocess()
|
||||
assert result.ret == 0
|
||||
result.stdout.fnmatch_lines([
|
||||
"*2 passed*",
|
||||
@@ -793,12 +793,12 @@ def test_customized_python_discovery_functions(testdir):
|
||||
def _test_underscore():
|
||||
pass
|
||||
""")
|
||||
result = testdir.inline_runpytest("--collect-only", "-s")
|
||||
result = testdir.runpytest_inprocess("--collect-only", "-s")
|
||||
result.stdout.fnmatch_lines([
|
||||
"*_test_underscore*",
|
||||
])
|
||||
|
||||
result = testdir.inline_runpytest()
|
||||
result = testdir.runpytest_inprocess()
|
||||
assert result.ret == 0
|
||||
result.stdout.fnmatch_lines([
|
||||
"*1 passed*",
|
||||
@@ -818,7 +818,7 @@ def test_collector_attributes(testdir):
|
||||
def test_hello():
|
||||
pass
|
||||
""")
|
||||
result = testdir.inline_runpytest()
|
||||
result = testdir.runpytest_inprocess()
|
||||
result.stdout.fnmatch_lines([
|
||||
"*1 passed*",
|
||||
])
|
||||
@@ -842,7 +842,7 @@ def test_customize_through_attributes(testdir):
|
||||
def test_hello(self):
|
||||
pass
|
||||
""")
|
||||
result = testdir.inline_runpytest("--collect-only")
|
||||
result = testdir.runpytest_inprocess("--collect-only")
|
||||
result.stdout.fnmatch_lines([
|
||||
"*MyClass*",
|
||||
"*MyInstance*",
|
||||
@@ -862,6 +862,6 @@ def test_unorderable_types(testdir):
|
||||
return Test
|
||||
TestFoo = make_test()
|
||||
""")
|
||||
result = testdir.inline_runpytest()
|
||||
result = testdir.runpytest_inprocess()
|
||||
assert "TypeError" not in result.stdout.str()
|
||||
assert result.ret == 0
|
||||
|
||||
Reference in New Issue
Block a user