File tree 3 files changed +16
-9
lines changed 3 files changed +16
-9
lines changed Original file line number Diff line number Diff line change
1
+ Terminal writer now takes into account unicode character width when writing out progress.
Original file line number Diff line number Diff line change @@ -59,7 +59,7 @@ def get_environment_marker_support_level():
59
59
def main ():
60
60
extras_require = {}
61
61
install_requires = [
62
- "py>=1.5.0" ,
62
+ "py>=1.5.0" , # if py gets upgrade to >=1.6, remove _width_of_current_line in terminal.py
63
63
"six>=1.10.0" ,
64
64
"setuptools" ,
65
65
"attrs>=17.4.0" ,
Original file line number Diff line number Diff line change @@ -412,10 +412,8 @@ def pytest_runtest_logfinish(self, nodeid):
412
412
if last_item :
413
413
self ._write_progress_information_filling_space ()
414
414
else :
415
- past_edge = (
416
- self ._tw .chars_on_current_line + self ._PROGRESS_LENGTH + 1
417
- >= self ._screen_width
418
- )
415
+ w = self ._width_of_current_line
416
+ past_edge = w + self ._PROGRESS_LENGTH + 1 >= self ._screen_width
419
417
if past_edge :
420
418
msg = self ._get_progress_information_message ()
421
419
self ._tw .write (msg + "\n " , cyan = True )
@@ -433,10 +431,18 @@ def _get_progress_information_message(self):
433
431
434
432
def _write_progress_information_filling_space (self ):
435
433
msg = self ._get_progress_information_message ()
436
- fill = " " * (
437
- self ._tw .fullwidth - self ._tw .chars_on_current_line - len (msg ) - 1
438
- )
439
- self .write (fill + msg , cyan = True )
434
+ w = self ._width_of_current_line
435
+ fill = self ._tw .fullwidth - w - 1
436
+ self .write (msg .rjust (fill ), cyan = True )
437
+
438
+ @property
439
+ def _width_of_current_line (self ):
440
+ """Return the width of current line, using the superior implementation of py-1.6 when available"""
441
+ try :
442
+ return self ._tw .width_of_current_line
443
+ except AttributeError :
444
+ # py < 1.6.0
445
+ return self ._tw .chars_on_current_line
440
446
441
447
def pytest_collection (self ):
442
448
if not self .isatty and self .config .option .verbose >= 1 :
You can’t perform that action at this time.
0 commit comments