Skip to content

Commit b9ebffb

Browse files
committed
#3374 fix comments
1 parent 0ed67c7 commit b9ebffb

File tree

1 file changed

+27
-14
lines changed

1 file changed

+27
-14
lines changed

_pytest/terminal.py

+27-14
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ def __init__(self, config, file=None):
186186
# self.writer will be deprecated in pytest-3.4
187187
self.writer = self._tw
188188
self._screen_width = self._tw.fullwidth
189-
self.is_fspath_extra_width = False
189+
self._is_fspath_past_edge = False
190190
self.currentfspath = None
191191
self.reportchars = getreportopt(config)
192192
self.hasmarkup = self._tw.hasmarkup
@@ -217,11 +217,11 @@ def write_fspath_result(self, nodeid, res):
217217
fspath = self.startdir.bestrelpath(fspath)
218218
self._tw.line()
219219
self._tw.write(fspath + " ")
220-
width = self._tw.fullwidth - self._tw.chars_on_current_line
221-
if 0 < width < 10 or self._tw.chars_on_current_line % self._screen_width > self._screen_width - 10:
220+
221+
if self._screen_width - self._MAX_LEN_LEFT <= self._tw.chars_on_current_line % self._screen_width:
222222
self._tw.line()
223-
elif width < 0:
224-
self.is_fspath_extra_width = True
223+
if self._tw.fullwidth - self._tw.chars_on_current_line < 0:
224+
self._is_fspath_past_edge = True
225225
self._tw.write(res)
226226

227227
def write_ensure_prefix(self, prefix, extra="", **kwargs):
@@ -361,13 +361,26 @@ def pytest_runtest_logfinish(self, nodeid):
361361
self._write_progress_information_filling_space()
362362
else:
363363
past_edge = self._tw.chars_on_current_line + self._PROGRESS_LENGTH + 1 >= self._screen_width
364-
width = self._tw.chars_on_current_line % self._screen_width + 9
365-
if past_edge and self.is_fspath_extra_width and width >= self._screen_width:
366-
self.is_fspath_extra_width = False
367-
elif past_edge and not self.is_fspath_extra_width:
368-
msg = self._get_progress_information_message()
369-
self._tw.write(msg + '\n', cyan=True)
370-
364+
width = self._tw.chars_on_current_line % self._screen_width + self._MAX_LEN_LEFT + 1
365+
# if past_edge and self.is_fspath_extra_width and width >= self._screen_width:
366+
if past_edge:
367+
if self._is_fspath_past_edge and width > self._screen_width:
368+
self._is_fspath_past_edge = False
369+
# print('HEY')
370+
# msg = self._get_progress_information_message()
371+
# self._tw.write(msg + '\n', cyan=True)
372+
# elif not self.is_fspath_extra_width:
373+
if not self._is_fspath_past_edge:
374+
msg = self._get_progress_information_message()
375+
self._tw.write(msg + '\n', cyan=True)
376+
# if not self.is_fspath_extra_width:
377+
# msg = self._get_progress_information_message()
378+
# self._tw.write(msg + '\n', cyan=True)
379+
# elif past_edge and not self.is_fspath_extra_width:
380+
# msg = self._get_progress_information_message()
381+
# self._tw.write(msg + '\n', cyan=True)
382+
383+
_MAX_LEN_LEFT = len('. [ 80%]')
371384
_PROGRESS_LENGTH = len(' [100%]')
372385

373386
def _get_progress_information_message(self):
@@ -381,9 +394,9 @@ def _get_progress_information_message(self):
381394

382395
def _write_progress_information_filling_space(self):
383396
msg = self._get_progress_information_message()
384-
if self.is_fspath_extra_width:
397+
if self._is_fspath_past_edge:
385398
fill = ' ' * (self._tw.fullwidth - self._tw.chars_on_current_line % self._screen_width - len(msg) - 1)
386-
self.is_fspath_extra_width = False
399+
self._is_fspath_past_edge = False
387400
else:
388401
fill = ' ' * (self._tw.fullwidth - self._tw.chars_on_current_line - len(msg) - 1)
389402
self.write(fill + msg, cyan=True)

0 commit comments

Comments
 (0)