Removed spacing in count display.

This commit is contained in:
Jeffrey Rackauckas 2018-08-27 20:23:17 -07:00
parent 23295e1e98
commit 4b94760c8e
3 changed files with 13 additions and 24 deletions

View File

@ -1 +1 @@
Added the ``progress_display_mode`` ini option to enable displaying the progress as a count instead of a percentage.
Added the ``count`` option to ``console_output_style`` to enable displaying the progress as a count instead of a percentage.

View File

@ -143,12 +143,6 @@ def pytest_addoption(parser):
default="progress",
)
parser.addini(
"progress_display_mode",
help="Controls how to show the test progress (percentage|count)",
default="percentage",
)
def pytest_configure(config):
reporter = TerminalReporter(config, sys.stdout)
@ -260,10 +254,7 @@ class TerminalReporter(object):
# do not show progress if we are showing fixture setup/teardown
if self.config.getoption("setupshow"):
return False
return (
self.config.getini("console_output_style") == "progress"
or self.config.getini("console_output_style") == "count"
)
return self.config.getini("console_output_style") in ("progress", "count")
def hasopt(self, char):
char = {"xfailed": "x", "skipped": "s"}.get(char, char)
@ -415,11 +406,9 @@ class TerminalReporter(object):
def pytest_runtest_logfinish(self, nodeid):
if self.config.getini("console_output_style") == "count":
num_tests = self._session.testscollected
_PROGRESS_LENGTH = len(
" [ {} / {} ]".format(str(num_tests), str(num_tests))
)
progress_length = len(" [{}/{}]".format(str(num_tests), str(num_tests)))
else:
_PROGRESS_LENGTH = len(" [100%]")
progress_length = len(" [100%]")
if self.verbosity <= 0 and self._show_progress_info:
self._progress_nodeids_reported.add(nodeid)
@ -430,7 +419,7 @@ class TerminalReporter(object):
self._write_progress_information_filling_space()
else:
past_edge = (
self._tw.chars_on_current_line + _PROGRESS_LENGTH + 1
self._tw.chars_on_current_line + progress_length + 1
>= self._screen_width
)
if past_edge:
@ -445,7 +434,7 @@ class TerminalReporter(object):
if collected:
progress = self._progress_nodeids_reported
counter_format = "{{:{}d}}".format(len(str(collected)))
format_string = " [ {} / {{}} ]".format(counter_format)
format_string = " [{}/{{}}]".format(counter_format)
return format_string.format(len(progress), collected)
return " [ {} / {} ]".format(collected, collected)
else:

View File

@ -1153,9 +1153,9 @@ class TestProgress(object):
output = testdir.runpytest()
output.stdout.re_match_lines(
[
r"test_bar.py \.{10} \s+ \[ 10 / 20 \]",
r"test_foo.py \.{5} \s+ \[ 15 / 20 \]",
r"test_foobar.py \.{5} \s+ \[ 20 / 20 \]",
r"test_bar.py \.{10} \s+ \[10/20\]",
r"test_foo.py \.{5} \s+ \[15/20\]",
r"test_foobar.py \.{5} \s+ \[20/20\]",
]
)
@ -1179,9 +1179,9 @@ class TestProgress(object):
output = testdir.runpytest("-v")
output.stdout.re_match_lines(
[
r"test_bar.py::test_bar\[0\] PASSED \s+ \[ 1 / 20 \]",
r"test_foo.py::test_foo\[4\] PASSED \s+ \[ 15 / 20 \]",
r"test_foobar.py::test_foobar\[4\] PASSED \s+ \[ 20 / 20 \]",
r"test_bar.py::test_bar\[0\] PASSED \s+ \[ 1/20\]",
r"test_foo.py::test_foo\[4\] PASSED \s+ \[15/20\]",
r"test_foobar.py::test_foobar\[4\] PASSED \s+ \[20/20\]",
]
)
@ -1199,7 +1199,7 @@ class TestProgress(object):
"""
)
output = testdir.runpytest("-n2")
output.stdout.re_match_lines([r"\.{20} \s+ \[ 20 / 20 \]"])
output.stdout.re_match_lines([r"\.{20} \s+ \[20/20\]"])
def test_xdist_verbose(self, many_tests_files, testdir):
pytest.importorskip("xdist")