Removed spacing in count display.
This commit is contained in:
parent
23295e1e98
commit
4b94760c8e
|
@ -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.
|
||||||
|
|
|
@ -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:
|
||||||
|
@ -445,7 +434,7 @@ class TerminalReporter(object):
|
||||||
if collected:
|
if collected:
|
||||||
progress = self._progress_nodeids_reported
|
progress = self._progress_nodeids_reported
|
||||||
counter_format = "{{:{}d}}".format(len(str(collected)))
|
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_string.format(len(progress), collected)
|
||||||
return " [ {} / {} ]".format(collected, collected)
|
return " [ {} / {} ]".format(collected, collected)
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -1153,9 +1153,9 @@ class TestProgress(object):
|
||||||
output = testdir.runpytest()
|
output = testdir.runpytest()
|
||||||
output.stdout.re_match_lines(
|
output.stdout.re_match_lines(
|
||||||
[
|
[
|
||||||
r"test_bar.py \.{10} \s+ \[ 10 / 20 \]",
|
r"test_bar.py \.{10} \s+ \[10/20\]",
|
||||||
r"test_foo.py \.{5} \s+ \[ 15 / 20 \]",
|
r"test_foo.py \.{5} \s+ \[15/20\]",
|
||||||
r"test_foobar.py \.{5} \s+ \[ 20 / 20 \]",
|
r"test_foobar.py \.{5} \s+ \[20/20\]",
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -1179,9 +1179,9 @@ class TestProgress(object):
|
||||||
output = testdir.runpytest("-v")
|
output = testdir.runpytest("-v")
|
||||||
output.stdout.re_match_lines(
|
output.stdout.re_match_lines(
|
||||||
[
|
[
|
||||||
r"test_bar.py::test_bar\[0\] PASSED \s+ \[ 1 / 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_foo.py::test_foo\[4\] PASSED \s+ \[15/20\]",
|
||||||
r"test_foobar.py::test_foobar\[4\] PASSED \s+ \[ 20 / 20 \]",
|
r"test_foobar.py::test_foobar\[4\] PASSED \s+ \[20/20\]",
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -1199,7 +1199,7 @@ class TestProgress(object):
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
output = testdir.runpytest("-n2")
|
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):
|
def test_xdist_verbose(self, many_tests_files, testdir):
|
||||||
pytest.importorskip("xdist")
|
pytest.importorskip("xdist")
|
||||||
|
|
Loading…
Reference in New Issue