From 1a7dcd73cf38f07ccaa4bd19c476750a1c678cbc Mon Sep 17 00:00:00 2001 From: Alan Velasco Date: Sat, 9 Jun 2018 16:58:23 -0700 Subject: [PATCH 1/2] Add a default value to CallInfo.result --- changelog/3554.bugfix | 1 + src/_pytest/runner.py | 1 + testing/test_runner.py | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 changelog/3554.bugfix diff --git a/changelog/3554.bugfix b/changelog/3554.bugfix new file mode 100644 index 000000000..3e2fdfc20 --- /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) From 198e993969ddf9ecb137150760565fccc773f11c Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Sat, 9 Jun 2018 21:31:32 -0300 Subject: [PATCH 2/2] Format CHANGELOG --- changelog/3554.bugfix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog/3554.bugfix b/changelog/3554.bugfix index 3e2fdfc20..4a10d71ee 100644 --- a/changelog/3554.bugfix +++ b/changelog/3554.bugfix @@ -1 +1 @@ -Allow CallInfo to have an unfinished state represented by having a None value in the result attribute. +Allow ``CallInfo`` to have an unfinished state represented by having a ``None`` value in the ``result`` attribute.