From 0f5fb7ed05c7911bbfe1583491f735c205453c34 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Wed, 29 Nov 2017 00:54:14 +0100 Subject: [PATCH] Fix ZeroDivisionError with 0 collected tests This can easily happen with pytest-testmon. --- _pytest/terminal.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/_pytest/terminal.py b/_pytest/terminal.py index 8538ee6aa..c5cbe14a1 100644 --- a/_pytest/terminal.py +++ b/_pytest/terminal.py @@ -313,8 +313,11 @@ class TerminalReporter: _PROGRESS_LENGTH = len(' [100%]') def _get_progress_information_message(self): - progress = self._progress_items_reported * 100 // self._session.testscollected - return ' [{:3d}%]'.format(progress) + collected = self._session.testscollected + if collected: + progress = self._progress_items_reported * 100 // collected + return ' [{:3d}%]'.format(progress) + return ' [100%]' def _write_progress_information_filling_space(self): if not self._show_progress_info: