make test suite more tolerable against xdist causing warnings itself (which it does
currently) --HG-- branch : plugtestfix
This commit is contained in:
parent
2d8f115d8c
commit
424e5d1394
|
@ -238,6 +238,13 @@ class RunResult:
|
||||||
d[cat] = int(num)
|
d[cat] = int(num)
|
||||||
return d
|
return d
|
||||||
|
|
||||||
|
def assertoutcome(self, passed=0, skipped=0, failed=0):
|
||||||
|
d = self.parseoutcomes()
|
||||||
|
assert passed == d.get("passed", 0)
|
||||||
|
assert skipped == d.get("skipped", 0)
|
||||||
|
assert failed == d.get("failed", 0)
|
||||||
|
|
||||||
|
|
||||||
class TmpTestdir:
|
class TmpTestdir:
|
||||||
"""Temporary test directory with tools to test/run py.test itself.
|
"""Temporary test directory with tools to test/run py.test itself.
|
||||||
|
|
||||||
|
@ -872,6 +879,7 @@ class LineComp:
|
||||||
lines1 = val.split("\n")
|
lines1 = val.split("\n")
|
||||||
return LineMatcher(lines1).fnmatch_lines(lines2)
|
return LineMatcher(lines1).fnmatch_lines(lines2)
|
||||||
|
|
||||||
|
|
||||||
class LineMatcher:
|
class LineMatcher:
|
||||||
"""Flexible matching of text.
|
"""Flexible matching of text.
|
||||||
|
|
||||||
|
|
|
@ -58,14 +58,10 @@ class TestClass:
|
||||||
class TestClass1:
|
class TestClass1:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
pass
|
pass
|
||||||
class TestClass2(object):
|
|
||||||
def __init__(self):
|
|
||||||
pass
|
|
||||||
""")
|
""")
|
||||||
result = testdir.runpytest("-rw")
|
result = testdir.runpytest("-rw")
|
||||||
result.stdout.fnmatch_lines("""
|
result.stdout.fnmatch_lines_random("""
|
||||||
WC1*test_class_with_init_warning.py*__init__*
|
WC1*test_class_with_init_warning.py*__init__*
|
||||||
*2 warnings*
|
|
||||||
""")
|
""")
|
||||||
|
|
||||||
def test_class_subclassobject(self, testdir):
|
def test_class_subclassobject(self, testdir):
|
||||||
|
|
|
@ -375,9 +375,7 @@ class TestMetafuncFunctional:
|
||||||
assert metafunc.cls == TestClass
|
assert metafunc.cls == TestClass
|
||||||
""")
|
""")
|
||||||
result = testdir.runpytest(p, "-v")
|
result = testdir.runpytest(p, "-v")
|
||||||
result.stdout.fnmatch_lines([
|
result.assertoutcome(passed=2)
|
||||||
"*2 passed in*",
|
|
||||||
])
|
|
||||||
|
|
||||||
def test_addcall_with_two_funcargs_generators(self, testdir):
|
def test_addcall_with_two_funcargs_generators(self, testdir):
|
||||||
testdir.makeconftest("""
|
testdir.makeconftest("""
|
||||||
|
|
|
@ -368,9 +368,8 @@ class TestWarning:
|
||||||
def pytest_configure(config):
|
def pytest_configure(config):
|
||||||
config.warn("C1", "hello")
|
config.warn("C1", "hello")
|
||||||
def pytest_logwarning(code, message):
|
def pytest_logwarning(code, message):
|
||||||
assert code == "C1"
|
if message == "hello" and code == "C1":
|
||||||
assert message == "hello"
|
l.append(1)
|
||||||
l.append(1)
|
|
||||||
""")
|
""")
|
||||||
testdir.makepyfile("""
|
testdir.makepyfile("""
|
||||||
def test_proper(pytestconfig):
|
def test_proper(pytestconfig):
|
||||||
|
@ -391,15 +390,13 @@ class TestWarning:
|
||||||
pass
|
pass
|
||||||
""")
|
""")
|
||||||
result = testdir.runpytest()
|
result = testdir.runpytest()
|
||||||
result.stdout.fnmatch_lines("""
|
assert result.parseoutcomes()["warnings"] > 0
|
||||||
*1 warning*
|
|
||||||
""")
|
|
||||||
assert "hello" not in result.stdout.str()
|
assert "hello" not in result.stdout.str()
|
||||||
|
|
||||||
result = testdir.runpytest("-rw")
|
result = testdir.runpytest("-rw")
|
||||||
result.stdout.fnmatch_lines("""
|
result.stdout.fnmatch_lines("""
|
||||||
===*warning summary*===
|
===*warning summary*===
|
||||||
*WT1*test_warn_on_test_item*:5*hello*
|
*WT1*test_warn_on_test_item*:5*hello*
|
||||||
*1 warning*
|
|
||||||
""")
|
""")
|
||||||
|
|
||||||
class TestRootdir:
|
class TestRootdir:
|
||||||
|
|
|
@ -339,9 +339,7 @@ def test_SkipTest_during_collection(testdir):
|
||||||
assert False
|
assert False
|
||||||
""")
|
""")
|
||||||
result = testdir.runpytest(p)
|
result = testdir.runpytest(p)
|
||||||
outcome = result.parseoutcomes()
|
result.assertoutcome(skipped=1)
|
||||||
outcome.pop('seconds')
|
|
||||||
assert outcome == dict(skipped=1)
|
|
||||||
|
|
||||||
|
|
||||||
def test_SkipTest_in_test(testdir):
|
def test_SkipTest_in_test(testdir):
|
||||||
|
|
|
@ -412,7 +412,7 @@ class TestTerminalFunctional:
|
||||||
py.std.sys.platform, verinfo,
|
py.std.sys.platform, verinfo,
|
||||||
py.__version__, pytest.__version__),
|
py.__version__, pytest.__version__),
|
||||||
"*test_header_trailer_info.py .",
|
"*test_header_trailer_info.py .",
|
||||||
"=* 1 passed in *.[0-9][0-9] seconds *=",
|
"=* 1 passed*in *.[0-9][0-9] seconds *=",
|
||||||
])
|
])
|
||||||
if pytest.config.pluginmanager._plugin_distinfo:
|
if pytest.config.pluginmanager._plugin_distinfo:
|
||||||
result.stdout.fnmatch_lines([
|
result.stdout.fnmatch_lines([
|
||||||
|
|
2
tox.ini
2
tox.ini
|
@ -34,7 +34,7 @@ basepython=python3.3
|
||||||
deps={[testenv:py27-xdist]deps}
|
deps={[testenv:py27-xdist]deps}
|
||||||
commands=
|
commands=
|
||||||
py.test -n3 -rfsxX \
|
py.test -n3 -rfsxX \
|
||||||
--junitxml={envlogdir}/junit-{envname}.xml testing
|
--junitxml={envlogdir}/junit-{envname}.xml {posargs:testing}
|
||||||
|
|
||||||
[testenv:py27-pexpect]
|
[testenv:py27-pexpect]
|
||||||
changedir=testing
|
changedir=testing
|
||||||
|
|
Loading…
Reference in New Issue