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