diff --git a/changelog/3554.bugfix b/changelog/3554.bugfix new file mode 100644 index 000000000..4a10d71ee --- /dev/null +++ b/changelog/3554.bugfix @@ -0,0 +1 @@ +Allow ``CallInfo`` to have an unfinished state represented by having a ``None`` value in the ``result`` attribute. diff --git a/src/_pytest/runner.py b/src/_pytest/runner.py index ef1a0e694..b8ba70fa0 100644 --- a/src/_pytest/runner.py +++ b/src/_pytest/runner.py @@ -194,6 +194,7 @@ class CallInfo(object): #: "teardown", "memocollect" self.when = when self.start = time() + self.result = None try: self.result = func() except KeyboardInterrupt: diff --git a/testing/test_runner.py b/testing/test_runner.py index 26493de6e..9085dbe9a 100644 --- a/testing/test_runner.py +++ b/testing/test_runner.py @@ -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)