From 91404db2849eb38fcbf47e46ebbac3e9c60c1023 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Wed, 7 Nov 2018 22:45:27 +0100 Subject: [PATCH] Fix TypeError in report_collect with _collect_report_last_write `_collect_report_last_write` might be None, when `pytest_collection` was not called before. Not sure if this indicates another problem, but it can be reproduced with `testing/test_collection.py::TestCollector::()::test_getcustomfile_roundtrip`. Fixes https://github.com/pytest-dev/pytest/issues/4329 --- changelog/4329.bugfix.rst | 1 + src/_pytest/terminal.py | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 changelog/4329.bugfix.rst diff --git a/changelog/4329.bugfix.rst b/changelog/4329.bugfix.rst new file mode 100644 index 000000000..6acfe7e61 --- /dev/null +++ b/changelog/4329.bugfix.rst @@ -0,0 +1 @@ +Fix TypeError in report_collect with _collect_report_last_write. diff --git a/src/_pytest/terminal.py b/src/_pytest/terminal.py index a00dc0842..dde2750be 100644 --- a/src/_pytest/terminal.py +++ b/src/_pytest/terminal.py @@ -497,7 +497,10 @@ class TerminalReporter(object): if not final: # Only write "collecting" report every 0.5s. t = time.time() - if self._collect_report_last_write > t - 0.5: + if ( + self._collect_report_last_write is not None + and self._collect_report_last_write > t - 0.5 + ): return self._collect_report_last_write = t