add a reportchar for reporting errors, fixes #76
This commit is contained in:
parent
f2512017ea
commit
6ac638ba87
|
@ -169,21 +169,23 @@ def pytest_terminal_summary(terminalreporter):
|
||||||
elif char == "X":
|
elif char == "X":
|
||||||
show_xpassed(terminalreporter, lines)
|
show_xpassed(terminalreporter, lines)
|
||||||
elif char in "fF":
|
elif char in "fF":
|
||||||
show_failed(terminalreporter, lines)
|
show_simple(terminalreporter, lines, 'failed', "FAIL %s")
|
||||||
elif char in "sS":
|
elif char in "sS":
|
||||||
show_skipped(terminalreporter, lines)
|
show_skipped(terminalreporter, lines)
|
||||||
|
elif char == "E":
|
||||||
|
show_simple(terminalreporter, lines, 'error', "ERROR %s")
|
||||||
if lines:
|
if lines:
|
||||||
tr._tw.sep("=", "short test summary info")
|
tr._tw.sep("=", "short test summary info")
|
||||||
for line in lines:
|
for line in lines:
|
||||||
tr._tw.line(line)
|
tr._tw.line(line)
|
||||||
|
|
||||||
def show_failed(terminalreporter, lines):
|
def show_simple(terminalreporter, lines, stat, format):
|
||||||
tw = terminalreporter._tw
|
tw = terminalreporter._tw
|
||||||
failed = terminalreporter.stats.get("failed")
|
failed = terminalreporter.stats.get(stat)
|
||||||
if failed:
|
if failed:
|
||||||
for rep in failed:
|
for rep in failed:
|
||||||
pos = rep.nodeid
|
pos = rep.nodeid
|
||||||
lines.append("FAIL %s" %(pos, ))
|
lines.append(format %(pos, ))
|
||||||
|
|
||||||
def show_xfailed(terminalreporter, lines):
|
def show_xfailed(terminalreporter, lines):
|
||||||
xfailed = terminalreporter.stats.get("xfailed")
|
xfailed = terminalreporter.stats.get("xfailed")
|
||||||
|
|
|
@ -15,7 +15,7 @@ def pytest_addoption(parser):
|
||||||
group._addoption('-r',
|
group._addoption('-r',
|
||||||
action="store", dest="reportchars", default=None, metavar="chars",
|
action="store", dest="reportchars", default=None, metavar="chars",
|
||||||
help="show extra test summary info as specified by chars (f)ailed, "
|
help="show extra test summary info as specified by chars (f)ailed, "
|
||||||
"(s)skipped, (x)failed, (X)passed.")
|
"(E)error, (s)skipped, (x)failed, (X)passed.")
|
||||||
group._addoption('-l', '--showlocals',
|
group._addoption('-l', '--showlocals',
|
||||||
action="store_true", dest="showlocals", default=False,
|
action="store_true", dest="showlocals", default=False,
|
||||||
help="show locals in tracebacks (disabled by default).")
|
help="show locals in tracebacks (disabled by default).")
|
||||||
|
|
|
@ -472,6 +472,21 @@ def test_reportchars(testdir):
|
||||||
"SKIP*four*",
|
"SKIP*four*",
|
||||||
])
|
])
|
||||||
|
|
||||||
|
def test_reportchars_error(testdir):
|
||||||
|
testdir.makepyfile(
|
||||||
|
conftest="""
|
||||||
|
def pytest_runtest_teardown():
|
||||||
|
assert 0
|
||||||
|
""",
|
||||||
|
test_simple="""
|
||||||
|
def test_foo():
|
||||||
|
pass
|
||||||
|
""")
|
||||||
|
result = testdir.runpytest('-rE')
|
||||||
|
result.stdout.fnmatch_lines([
|
||||||
|
'ERROR*test_foo*',
|
||||||
|
])
|
||||||
|
|
||||||
@pytest.mark.xfail("hasattr(sys, 'pypy_version_info')")
|
@pytest.mark.xfail("hasattr(sys, 'pypy_version_info')")
|
||||||
def test_errors_in_xfail_skip_expressions(testdir):
|
def test_errors_in_xfail_skip_expressions(testdir):
|
||||||
testdir.makepyfile("""
|
testdir.makepyfile("""
|
||||||
|
|
Loading…
Reference in New Issue