Merge pull request #3560 from alanbato/fix_callinfo_rrp

Add a default value to CallInfo.result
This commit is contained in:
Alan Velasco 2018-06-09 21:20:56 -07:00 committed by GitHub
commit 80f8a3ad7c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 1 deletions

1
changelog/3554.bugfix Normal file
View File

@ -0,0 +1 @@
Allow ``CallInfo`` to have an unfinished state represented by having a ``None`` value in the ``result`` attribute.

View File

@ -194,6 +194,7 @@ class CallInfo(object):
#: "teardown", "memocollect" #: "teardown", "memocollect"
self.when = when self.when = when
self.start = time() self.start = time()
self.result = None
try: try:
self.result = func() self.result = func()
except KeyboardInterrupt: except KeyboardInterrupt:

View File

@ -473,7 +473,7 @@ def test_callinfo():
assert "result" in repr(ci) assert "result" in repr(ci)
ci = runner.CallInfo(lambda: 0 / 0, "123") ci = runner.CallInfo(lambda: 0 / 0, "123")
assert ci.when == "123" assert ci.when == "123"
assert not hasattr(ci, "result") assert ci.result is None
assert ci.excinfo assert ci.excinfo
assert "exc" in repr(ci) assert "exc" in repr(ci)