make test suite more tolerable against xdist causing warnings itself (which it does

currently)

--HG--
branch : plugtestfix
This commit is contained in:
holger krekel 2015-04-27 15:06:47 +02:00
parent 2d8f115d8c
commit 424e5d1394
7 changed files with 17 additions and 20 deletions

View File

@ -238,6 +238,13 @@ class RunResult:
d[cat] = int(num)
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:
"""Temporary test directory with tools to test/run py.test itself.
@ -872,6 +879,7 @@ class LineComp:
lines1 = val.split("\n")
return LineMatcher(lines1).fnmatch_lines(lines2)
class LineMatcher:
"""Flexible matching of text.

View File

@ -58,14 +58,10 @@ class TestClass:
class TestClass1:
def __init__(self):
pass
class TestClass2(object):
def __init__(self):
pass
""")
result = testdir.runpytest("-rw")
result.stdout.fnmatch_lines("""
result.stdout.fnmatch_lines_random("""
WC1*test_class_with_init_warning.py*__init__*
*2 warnings*
""")
def test_class_subclassobject(self, testdir):

View File

@ -375,9 +375,7 @@ class TestMetafuncFunctional:
assert metafunc.cls == TestClass
""")
result = testdir.runpytest(p, "-v")
result.stdout.fnmatch_lines([
"*2 passed in*",
])
result.assertoutcome(passed=2)
def test_addcall_with_two_funcargs_generators(self, testdir):
testdir.makeconftest("""

View File

@ -368,8 +368,7 @@ class TestWarning:
def pytest_configure(config):
config.warn("C1", "hello")
def pytest_logwarning(code, message):
assert code == "C1"
assert message == "hello"
if message == "hello" and code == "C1":
l.append(1)
""")
testdir.makepyfile("""
@ -391,15 +390,13 @@ class TestWarning:
pass
""")
result = testdir.runpytest()
result.stdout.fnmatch_lines("""
*1 warning*
""")
assert result.parseoutcomes()["warnings"] > 0
assert "hello" not in result.stdout.str()
result = testdir.runpytest("-rw")
result.stdout.fnmatch_lines("""
===*warning summary*===
*WT1*test_warn_on_test_item*:5*hello*
*1 warning*
""")
class TestRootdir:

View File

@ -339,9 +339,7 @@ def test_SkipTest_during_collection(testdir):
assert False
""")
result = testdir.runpytest(p)
outcome = result.parseoutcomes()
outcome.pop('seconds')
assert outcome == dict(skipped=1)
result.assertoutcome(skipped=1)
def test_SkipTest_in_test(testdir):

View File

@ -412,7 +412,7 @@ class TestTerminalFunctional:
py.std.sys.platform, verinfo,
py.__version__, pytest.__version__),
"*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:
result.stdout.fnmatch_lines([

View File

@ -34,7 +34,7 @@ basepython=python3.3
deps={[testenv:py27-xdist]deps}
commands=
py.test -n3 -rfsxX \
--junitxml={envlogdir}/junit-{envname}.xml testing
--junitxml={envlogdir}/junit-{envname}.xml {posargs:testing}
[testenv:py27-pexpect]
changedir=testing