Skip to content

Commit 80f8a3a

Browse files
authored
Merge pull request #3560 from alanbato/fix_callinfo_rrp
Add a default value to CallInfo.result
2 parents 7c8d072 + 198e993 commit 80f8a3a

File tree

3 files changed

+3
-1
lines changed

3 files changed

+3
-1
lines changed

changelog/3554.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Allow ``CallInfo`` to have an unfinished state represented by having a ``None`` value in the ``result`` attribute.

src/_pytest/runner.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ def __init__(self, func, when, treat_keyboard_interrupt_as_exception=False):
194194
#: "teardown", "memocollect"
195195
self.when = when
196196
self.start = time()
197+
self.result = None
197198
try:
198199
self.result = func()
199200
except KeyboardInterrupt:

testing/test_runner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ def test_callinfo():
473473
assert "result" in repr(ci)
474474
ci = runner.CallInfo(lambda: 0 / 0, "123")
475475
assert ci.when == "123"
476-
assert not hasattr(ci, "result")
476+
assert ci.result is None
477477
assert ci.excinfo
478478
assert "exc" in repr(ci)
479479

0 commit comments

Comments
 (0)