Skip to content

Add a default value to CallInfo.result #3560

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/3554.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Allow ``CallInfo`` to have an unfinished state represented by having a ``None`` value in the ``result`` attribute.
1 change: 1 addition & 0 deletions src/_pytest/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ def __init__(self, func, when, treat_keyboard_interrupt_as_exception=False):
#: "teardown", "memocollect"
self.when = when
self.start = time()
self.result = None
try:
self.result = func()
except KeyboardInterrupt:
Expand Down
2 changes: 1 addition & 1 deletion testing/test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ def test_callinfo():
assert "result" in repr(ci)
ci = runner.CallInfo(lambda: 0 / 0, "123")
assert ci.when == "123"
assert not hasattr(ci, "result")
assert ci.result is None
assert ci.excinfo
assert "exc" in repr(ci)

Expand Down