Skip to content

#3374 If path name is very long then pytest will split name for several lines #3383

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 30 additions & 4 deletions _pytest/terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand All @@ -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):
Expand Down
1 change: 1 addition & 0 deletions changelog/3374.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
If path name is very long then pytest will split name for several lines.