diff --git a/_pytest/terminal.py b/_pytest/terminal.py index f8ad33c1010..531f24996e8 100644 --- a/_pytest/terminal.py +++ b/_pytest/terminal.py @@ -186,6 +186,7 @@ def __init__(self, config, file=None): # self.writer will be deprecated in pytest-3.4 self.writer = self._tw self._screen_width = self._tw.fullwidth + self._is_fspath_past_edge = False self.currentfspath = None self.reportchars = getreportopt(config) self.hasmarkup = self._tw.hasmarkup @@ -216,6 +217,11 @@ def write_fspath_result(self, nodeid, res): fspath = self.startdir.bestrelpath(fspath) self._tw.line() self._tw.write(fspath + " ") + + if self._screen_width - self._MAX_LEN_LEFT <= self._tw.chars_on_current_line % self._screen_width: + self._tw.line() + if self._tw.fullwidth - self._tw.chars_on_current_line < 0: + self._is_fspath_past_edge = True self._tw.write(res) def write_ensure_prefix(self, prefix, extra="", **kwargs): @@ -355,10 +361,26 @@ def pytest_runtest_logfinish(self, nodeid): self._write_progress_information_filling_space() else: past_edge = self._tw.chars_on_current_line + self._PROGRESS_LENGTH + 1 >= self._screen_width + width = self._tw.chars_on_current_line % self._screen_width + self._MAX_LEN_LEFT + 1 + # if past_edge and self.is_fspath_extra_width and width >= self._screen_width: if past_edge: - msg = self._get_progress_information_message() - self._tw.write(msg + '\n', cyan=True) - + if self._is_fspath_past_edge and width > self._screen_width: + self._is_fspath_past_edge = False + # print('HEY') + # msg = self._get_progress_information_message() + # self._tw.write(msg + '\n', cyan=True) + # elif not self.is_fspath_extra_width: + if not self._is_fspath_past_edge: + msg = self._get_progress_information_message() + self._tw.write(msg + '\n', cyan=True) + # if not self.is_fspath_extra_width: + # msg = self._get_progress_information_message() + # self._tw.write(msg + '\n', cyan=True) + # elif past_edge and not self.is_fspath_extra_width: + # msg = self._get_progress_information_message() + # self._tw.write(msg + '\n', cyan=True) + + _MAX_LEN_LEFT = len('. [ 80%]') _PROGRESS_LENGTH = len(' [100%]') def _get_progress_information_message(self): @@ -372,7 +394,11 @@ def _get_progress_information_message(self): def _write_progress_information_filling_space(self): msg = self._get_progress_information_message() - fill = ' ' * (self._tw.fullwidth - self._tw.chars_on_current_line - len(msg) - 1) + if self._is_fspath_past_edge: + fill = ' ' * (self._tw.fullwidth - self._tw.chars_on_current_line % self._screen_width - len(msg) - 1) + self._is_fspath_past_edge = False + else: + fill = ' ' * (self._tw.fullwidth - self._tw.chars_on_current_line - len(msg) - 1) self.write(fill + msg, cyan=True) def pytest_collection(self): diff --git a/changelog/3374.feature b/changelog/3374.feature new file mode 100644 index 00000000000..130adeb294d --- /dev/null +++ b/changelog/3374.feature @@ -0,0 +1 @@ +If path name is very long then pytest will split name for several lines.