Commit d9f8a345 authored by Jérome Perrin's avatar Jérome Perrin

PyTest.summaryf: always report count of failures and errors

summaryf needs to always return the count of failures, errors, skips
for two reasons:

 - nxdtest sets error_count += 1 when the test program's returncode is
not zero, so if we don't set error_count explicitly, the number of
errors will be 1 when there are only failures
 - without error_count / failure_count, _test_result_summary does not
display the global test result as pass or fail but as ?

/reviewed-by @kirr
/reviewed-on nexedi/nxdtest!17
parent d30b73f0
...@@ -513,9 +513,7 @@ class PyTest: ...@@ -513,9 +513,7 @@ class PyTest:
stat = {'test_count': 0} stat = {'test_count': 0}
def stat_set(stat_key, from_name): def stat_set(stat_key, from_name):
v = get(from_name) v = get(from_name, 0)
if v is None:
return
stat[stat_key] = v stat[stat_key] = v
stat['test_count'] += v stat['test_count'] += v
stat_set('skip_count', 'skipped') stat_set('skip_count', 'skipped')
......
...@@ -27,6 +27,20 @@ from golang import b ...@@ -27,6 +27,20 @@ from golang import b
testv = [] testv = []
def case1(name, out, err, summaryok): testv.append((name, out, err, summaryok)) def case1(name, out, err, summaryok): testv.append((name, out, err, summaryok))
case1('ok', b("""\
============================== test session starts ===============================
platform linux -- Python 3.7.7, pytest-4.6.11, py-1.9.0, pluggy-0.13.1
rootdir: /srv/slapgrid/slappart15/srv/runner/software/104d3d67a7dca200da22b97280c85eb6/parts/nxdtest, inifile: pytest.ini
plugins: timeout-1.4.2, mock-2.0.0
collected 1 item
test.py . [100%]
============================ 1 passed in 0.01 seconds ============================
"""),
b(''),
'ok\ttestname\t1.000s\t# 1t 0e 0f 0s')
case1('ok+xfail', b("""\ case1('ok+xfail', b("""\
============================= test session starts ============================== ============================= test session starts ==============================
platform linux2 -- Python 2.7.18, pytest-4.6.11, py-1.9.0, pluggy-0.13.1 platform linux2 -- Python 2.7.18, pytest-4.6.11, py-1.9.0, pluggy-0.13.1
...@@ -42,7 +56,7 @@ zodbtools/test/test_zodb.py ........ [100%] ...@@ -42,7 +56,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(''), b(''),
'?\ttestname\t1.000s\t# 43t ?e ?f ?s') 'ok\ttestname\t1.000s\t# 43t 0e 0f 0s')
case1('ok+fail', b("""\ case1('ok+fail', b("""\
============================= test session starts ============================== ============================= test session starts ==============================
...@@ -115,7 +129,7 @@ golang/time_test.py:106: AssertionError ...@@ -115,7 +129,7 @@ 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(''), b(''),
'?\ttestname\t1.000s\t# 112t ?e 1f 13s') 'fail\ttestname\t1.000s\t# 112t 0e 1f 13s')
case1('ok+tailtext', b("""\ case1('ok+tailtext', b("""\
date: Sun, 08 Nov 2020 12:26:24 MSK date: Sun, 08 Nov 2020 12:26:24 MSK
...@@ -134,7 +148,7 @@ wcfs: 2020/11/08 12:26:38 /tmp/testdb_fs.B3rbby/1.fs: watcher: stat /tmp/testdb_ ...@@ -134,7 +148,7 @@ wcfs: 2020/11/08 12:26:38 /tmp/testdb_fs.B3rbby/1.fs: watcher: stat /tmp/testdb_
# unmount/stop wcfs pid39595 @ /tmp/wcfs/d0b5d036a2cce47fe73003cf2d9f0b22c7043817 # unmount/stop wcfs pid39595 @ /tmp/wcfs/d0b5d036a2cce47fe73003cf2d9f0b22c7043817
"""), """),
b(''), b(''),
'?\ttestname\t1.000s\t# 55t ?e ?f ?s') 'ok\ttestname\t1.000s\t# 55t 0e 0f 0s')
@pytest.mark.parametrize("name,out,err,summaryok", testv) @pytest.mark.parametrize("name,out,err,summaryok", testv)
......
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