Skip to content

Commit fb9dc72

Browse files
RibeiroAnasallner
authored andcommitted
Fixes issue related to rerun attribute on report (Issue #77) (#78)
* Fixes regression issue related to rerun attribute on report * Added credits
1 parent 12930fb commit fb9dc72

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

CHANGES.rst

+4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ Changelog
88

99
- Drop support for pytest version 3.6.
1010

11+
- Fixed #77 issue related to the ``rerun`` attribute on the test report. (Thanks to `@RibeiroAna`_ for the PR).
12+
13+
.. _@RibeiroAna: https://github.com/RibeiroAna
14+
1115

1216
5.0 (2018-11-06)
1317
================

pytest_rerunfailures.py

+1
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ def pytest_runtest_protocol(item, nextitem):
175175
reports = runtestprotocol(item, nextitem=nextitem, log=False)
176176

177177
for report in reports: # 3 reports: setup, call, teardown
178+
report.rerun = item.execution_count - 1
178179
xfail = hasattr(report, 'wasxfail')
179180
if item.execution_count > reruns or not report.failed or xfail:
180181
# last run or no failure detected, log normally

test_pytest_rerunfailures.py

+11
Original file line numberDiff line numberDiff line change
@@ -388,3 +388,14 @@ def pytest_runtest_teardown(item):
388388
assert item.execution_count == 3""")
389389
result = testdir.runpytest('--reruns', '2')
390390
assert_outcomes(result, passed=3, rerun=2)
391+
392+
def test_rerun_report(testdir):
393+
testdir.makepyfile('def test_pass(): assert False')
394+
testdir.makeconftest("""
395+
def pytest_runtest_logreport(report):
396+
assert hasattr(report, 'rerun')
397+
assert isinstance(report.rerun, int)
398+
assert report.rerun <= 2
399+
""")
400+
result = testdir.runpytest('--reruns', '2')
401+
assert_outcomes(result, failed=1, rerun=2, passed=0)

0 commit comments

Comments
 (0)