Commit 53064e71 authored by Jérome Perrin's avatar Jérome Perrin

Also pass stderr output to summary method

While pytest sends everything in stdout, some other programs send on stderr.
parent beb9d47e
...@@ -231,7 +231,7 @@ def main(): ...@@ -231,7 +231,7 @@ def main():
# postprocess output, if we can # postprocess output, if we can
if t.summaryf is not None: if t.summaryf is not None:
try: try:
summary = t.summaryf(stdout) summary = t.summaryf(stdout, stderr)
except: except:
bad = b(traceback.format_exc()) bad = b(traceback.format_exc())
bstderr.write(bad) bstderr.write(bad)
...@@ -357,7 +357,7 @@ class LocalTestResultLine: ...@@ -357,7 +357,7 @@ class LocalTestResultLine:
# support for well-known summary functions # support for well-known summary functions
class PyTest: class PyTest:
@staticmethod @staticmethod
def summary(out): # -> status_dict def summary(out, err): # -> status_dict
# end of output is like # end of output is like
# ================ 1 failed, 1 passed, 12 skipped in 0.39 seconds ================ # ================ 1 failed, 1 passed, 12 skipped in 0.39 seconds ================
# ... # ...
......
...@@ -23,9 +23,9 @@ from nxdtest import _test_result_summary, PyTest ...@@ -23,9 +23,9 @@ from nxdtest import _test_result_summary, PyTest
import pytest import pytest
from golang import b from golang import b
# [] of (name, out, summaryok) # [] of (name, out, err, summaryok)
testv = [] testv = []
def case1(name, out, summaryok): testv.append((name, out, summaryok)) def case1(name, out, err, summaryok): testv.append((name, out, err, summaryok))
case1('ok+xfail', b("""\ case1('ok+xfail', b("""\
============================= test session starts ============================== ============================= test session starts ==============================
...@@ -41,6 +41,7 @@ zodbtools/test/test_zodb.py ........ [100%] ...@@ -41,6 +41,7 @@ zodbtools/test/test_zodb.py ........ [100%]
=============== 41 passed, 2 xfailed, 1 warnings in 4.62 seconds =============== =============== 41 passed, 2 xfailed, 1 warnings in 4.62 seconds ===============
"""), """),
b(''),
'?\ttestname\t1.000s\t# 43t ?e ?f ?s') '?\ttestname\t1.000s\t# 43t ?e ?f ?s')
case1('ok+fail', b("""\ case1('ok+fail', b("""\
...@@ -113,6 +114,7 @@ E Use -v to get the full diff ...@@ -113,6 +114,7 @@ E Use -v to get the full diff
golang/time_test.py:106: AssertionError golang/time_test.py:106: AssertionError
=============== 1 failed, 98 passed, 13 skipped in 26.85 seconds =============== =============== 1 failed, 98 passed, 13 skipped in 26.85 seconds ===============
"""), """),
b(''),
'?\ttestname\t1.000s\t# 112t ?e 1f 13s') '?\ttestname\t1.000s\t# 112t ?e 1f 13s')
case1('ok+tailtext', b("""\ case1('ok+tailtext', b("""\
...@@ -131,12 +133,13 @@ wcfs: 2020/11/08 12:26:38 /tmp/testdb_fs.Z9IvT0/1.fs: watcher: stat /tmp/testdb_ ...@@ -131,12 +133,13 @@ wcfs: 2020/11/08 12:26:38 /tmp/testdb_fs.Z9IvT0/1.fs: watcher: stat /tmp/testdb_
wcfs: 2020/11/08 12:26:38 /tmp/testdb_fs.B3rbby/1.fs: watcher: stat /tmp/testdb_fs.B3rbby/1.fs: use of closed file wcfs: 2020/11/08 12:26:38 /tmp/testdb_fs.B3rbby/1.fs: watcher: stat /tmp/testdb_fs.B3rbby/1.fs: use of closed file
# unmount/stop wcfs pid39595 @ /tmp/wcfs/d0b5d036a2cce47fe73003cf2d9f0b22c7043817 # unmount/stop wcfs pid39595 @ /tmp/wcfs/d0b5d036a2cce47fe73003cf2d9f0b22c7043817
"""), """),
b(''),
'?\ttestname\t1.000s\t# 55t ?e ?f ?s') '?\ttestname\t1.000s\t# 55t ?e ?f ?s')
@pytest.mark.parametrize("name,out,summaryok", testv) @pytest.mark.parametrize("name,out,err,summaryok", testv)
def test_pytest_summary(name, out, summaryok): def test_pytest_summary(name, out, err, summaryok):
kw = {'duration': 1.0} kw = {'duration': 1.0}
kw.update(PyTest.summary(out)) kw.update(PyTest.summary(out, err))
summary = _test_result_summary('testname', kw) summary = _test_result_summary('testname', kw)
assert summary == summaryok assert summary == summaryok
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment