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
This commit is contained in:
Daniel Hahler 2018-11-07 22:45:27 +01:00
parent 64762d2cfc
commit 91404db284
2 changed files with 5 additions and 1 deletions

View File

@ -0,0 +1 @@
Fix TypeError in report_collect with _collect_report_last_write.

View File

@ -497,7 +497,10 @@ class TerminalReporter(object):
if not final: if not final:
# Only write "collecting" report every 0.5s. # Only write "collecting" report every 0.5s.
t = time.time() 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 return
self._collect_report_last_write = t self._collect_report_last_write = t