Skip to content

Commit 4b94760

Browse files
committed
Removed spacing in count display.
1 parent 23295e1 commit 4b94760

File tree

3 files changed

+13
-24
lines changed

3 files changed

+13
-24
lines changed

changelog/3829.feature.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Added the ``progress_display_mode`` ini option to enable displaying the progress as a count instead of a percentage.
1+
Added the ``count`` option to ``console_output_style`` to enable displaying the progress as a count instead of a percentage.

src/_pytest/terminal.py

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -143,12 +143,6 @@ def pytest_addoption(parser):
143143
default="progress",
144144
)
145145

146-
parser.addini(
147-
"progress_display_mode",
148-
help="Controls how to show the test progress (percentage|count)",
149-
default="percentage",
150-
)
151-
152146

153147
def pytest_configure(config):
154148
reporter = TerminalReporter(config, sys.stdout)
@@ -260,10 +254,7 @@ def _determine_show_progress_info(self):
260254
# do not show progress if we are showing fixture setup/teardown
261255
if self.config.getoption("setupshow"):
262256
return False
263-
return (
264-
self.config.getini("console_output_style") == "progress"
265-
or self.config.getini("console_output_style") == "count"
266-
)
257+
return self.config.getini("console_output_style") in ("progress", "count")
267258

268259
def hasopt(self, char):
269260
char = {"xfailed": "x", "skipped": "s"}.get(char, char)
@@ -415,11 +406,9 @@ def pytest_runtest_logreport(self, report):
415406
def pytest_runtest_logfinish(self, nodeid):
416407
if self.config.getini("console_output_style") == "count":
417408
num_tests = self._session.testscollected
418-
_PROGRESS_LENGTH = len(
419-
" [ {} / {} ]".format(str(num_tests), str(num_tests))
420-
)
409+
progress_length = len(" [{}/{}]".format(str(num_tests), str(num_tests)))
421410
else:
422-
_PROGRESS_LENGTH = len(" [100%]")
411+
progress_length = len(" [100%]")
423412

424413
if self.verbosity <= 0 and self._show_progress_info:
425414
self._progress_nodeids_reported.add(nodeid)
@@ -430,7 +419,7 @@ def pytest_runtest_logfinish(self, nodeid):
430419
self._write_progress_information_filling_space()
431420
else:
432421
past_edge = (
433-
self._tw.chars_on_current_line + _PROGRESS_LENGTH + 1
422+
self._tw.chars_on_current_line + progress_length + 1
434423
>= self._screen_width
435424
)
436425
if past_edge:
@@ -445,7 +434,7 @@ def _get_progress_information_message(self):
445434
if collected:
446435
progress = self._progress_nodeids_reported
447436
counter_format = "{{:{}d}}".format(len(str(collected)))
448-
format_string = " [ {} / {{}} ]".format(counter_format)
437+
format_string = " [{}/{{}}]".format(counter_format)
449438
return format_string.format(len(progress), collected)
450439
return " [ {} / {} ]".format(collected, collected)
451440
else:

testing/test_terminal.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,9 +1153,9 @@ def test_count(self, many_tests_files, testdir):
11531153
output = testdir.runpytest()
11541154
output.stdout.re_match_lines(
11551155
[
1156-
r"test_bar.py \.{10} \s+ \[ 10 / 20 \]",
1157-
r"test_foo.py \.{5} \s+ \[ 15 / 20 \]",
1158-
r"test_foobar.py \.{5} \s+ \[ 20 / 20 \]",
1156+
r"test_bar.py \.{10} \s+ \[10/20\]",
1157+
r"test_foo.py \.{5} \s+ \[15/20\]",
1158+
r"test_foobar.py \.{5} \s+ \[20/20\]",
11591159
]
11601160
)
11611161

@@ -1179,9 +1179,9 @@ def test_verbose_count(self, many_tests_files, testdir):
11791179
output = testdir.runpytest("-v")
11801180
output.stdout.re_match_lines(
11811181
[
1182-
r"test_bar.py::test_bar\[0\] PASSED \s+ \[ 1 / 20 \]",
1183-
r"test_foo.py::test_foo\[4\] PASSED \s+ \[ 15 / 20 \]",
1184-
r"test_foobar.py::test_foobar\[4\] PASSED \s+ \[ 20 / 20 \]",
1182+
r"test_bar.py::test_bar\[0\] PASSED \s+ \[ 1/20\]",
1183+
r"test_foo.py::test_foo\[4\] PASSED \s+ \[15/20\]",
1184+
r"test_foobar.py::test_foobar\[4\] PASSED \s+ \[20/20\]",
11851185
]
11861186
)
11871187

@@ -1199,7 +1199,7 @@ def test_xdist_normal_count(self, many_tests_files, testdir):
11991199
"""
12001200
)
12011201
output = testdir.runpytest("-n2")
1202-
output.stdout.re_match_lines([r"\.{20} \s+ \[ 20 / 20 \]"])
1202+
output.stdout.re_match_lines([r"\.{20} \s+ \[20/20\]"])
12031203

12041204
def test_xdist_verbose(self, many_tests_files, testdir):
12051205
pytest.importorskip("xdist")

0 commit comments

Comments
 (0)