diff --git a/Lib/test/regrtest.py b/Lib/test/regrtest.py --- a/Lib/test/regrtest.py +++ b/Lib/test/regrtest.py @@ -688,6 +688,11 @@ test_count = '/{}'.format(len(selected)) test_count_width = len(test_count) - 1 + if hasattr(sys.stdout, 'isatty') and sys.stdout.isatty(): + end, just = '\r', 45 + else: + end, just = '\n', 0 + if use_mp: try: from threading import Thread @@ -760,7 +765,7 @@ fmt = "[{1:{0}}{2}/{3}] {4}" if bad else "[{1:{0}}{2}] {4}" print(fmt.format( test_count_width, test_index, test_count, - len(bad), test)) + len(bad), test).ljust(just), end=end) if stdout: print(stdout) if stderr: @@ -782,7 +787,8 @@ if not quiet: fmt = "[{1:{0}}{2}/{3}] {4}" if bad else "[{1:{0}}{2}] {4}" print(fmt.format( - test_count_width, test_index, test_count, len(bad), test)) + test_count_width, test_index, test_count, + len(bad), test).ljust(just), end=end) sys.stdout.flush() if trace: # If we're tracing code coverage, then we don't exit with status