Skip to content

Commit 91404db

Browse files
committed
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 #4329
1 parent 64762d2 commit 91404db

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

changelog/4329.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix TypeError in report_collect with _collect_report_last_write.

src/_pytest/terminal.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,10 @@ def report_collect(self, final=False):
497497
if not final:
498498
# Only write "collecting" report every 0.5s.
499499
t = time.time()
500-
if self._collect_report_last_write > t - 0.5:
500+
if (
501+
self._collect_report_last_write is not None
502+
and self._collect_report_last_write > t - 0.5
503+
):
501504
return
502505
self._collect_report_last_write = t
503506

0 commit comments

Comments
 (0)