Skip to content

Commit 5a2d55e

Browse files
committed
Fix tests
1 parent 40ff876 commit 5a2d55e

File tree

5 files changed

+27
-6
lines changed

5 files changed

+27
-6
lines changed

_pytest/terminal.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ def pytest_addoption(parser):
5151
choices=['yes', 'no', 'auto'],
5252
help="color terminal output (yes/no/auto).")
5353

54+
parser.addini("console_output_style",
55+
help="console output: classic or with additional progress information.",
56+
default='progress')
57+
5458

5559
def pytest_configure(config):
5660
config.option.verbose -= config.option.quiet
@@ -148,6 +152,7 @@ def __init__(self, config, file=None):
148152
self.hasmarkup = self.writer.hasmarkup
149153
self.isatty = file.isatty()
150154
self._progress_items_reported = 0
155+
self._show_progress_info = self.config.getini('console_output_style') == 'progress'
151156

152157
@property
153158
def writer(self):
@@ -301,6 +306,8 @@ def pytest_runtest_logreport(self, report):
301306
self.currentfspath = -2
302307

303308
def _write_progress_if_past_edge(self):
309+
if not self._show_progress_info:
310+
return
304311
last_item = self._progress_items_reported == self._session.testscollected
305312
if last_item:
306313
self._write_progress_information_filling_space()
@@ -318,6 +325,8 @@ def _get_progress_information_message(self):
318325
return ' [{:3d}%]'.format(progress)
319326

320327
def _write_progress_information_filling_space(self):
328+
if not self._show_progress_info:
329+
return
321330
msg = self._get_progress_information_message()
322331
fill = ' ' * (self.writer.fullwidth - self.writer.chars_on_current_line - len(msg) - 1)
323332
self.write(fill + msg, cyan=True)

testing/acceptance_test.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -630,18 +630,18 @@ def join_pythonpath(*dirs):
630630
testdir.chdir()
631631
assert result.ret == 0
632632
result.stdout.fnmatch_lines([
633-
"*test_hello.py::test_hello*PASSED",
634-
"*test_hello.py::test_other*PASSED",
635-
"*test_world.py::test_world*PASSED",
636-
"*test_world.py::test_other*PASSED",
633+
"*test_hello.py::test_hello*PASSED*",
634+
"*test_hello.py::test_other*PASSED*",
635+
"*test_world.py::test_world*PASSED*",
636+
"*test_world.py::test_other*PASSED*",
637637
"*4 passed*"
638638
])
639639

640640
# specify tests within a module
641641
result = testdir.runpytest("--pyargs", "-v", "ns_pkg.world.test_world::test_other")
642642
assert result.ret == 0
643643
result.stdout.fnmatch_lines([
644-
"*test_world.py::test_other*PASSED",
644+
"*test_world.py::test_other*PASSED*",
645645
"*1 passed*"
646646
])
647647

testing/python/fixture.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2119,6 +2119,10 @@ def test_2(arg):
21192119
assert values == [1, 1, 2, 2]
21202120

21212121
def test_module_parametrized_ordering(self, testdir):
2122+
testdir.makeini("""
2123+
[pytest]
2124+
console_output_style=classic
2125+
""")
21222126
testdir.makeconftest("""
21232127
import pytest
21242128
@@ -2165,6 +2169,10 @@ def test_func4(marg):
21652169
""")
21662170

21672171
def test_class_ordering(self, testdir):
2172+
testdir.makeini("""
2173+
[pytest]
2174+
console_output_style=classic
2175+
""")
21682176
testdir.makeconftest("""
21692177
import pytest
21702178

testing/python/metafunc.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -960,6 +960,10 @@ def test_func(arg2):
960960
])
961961

962962
def test_parametrize_with_ids(self, testdir):
963+
testdir.makeini("""
964+
[pytest]
965+
console_output_style=classic
966+
""")
963967
testdir.makepyfile("""
964968
import pytest
965969
def pytest_generate_tests(metafunc):

testing/test_terminal.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ class TestMore(BaseTests):
147147
])
148148
result = testdir.runpytest("-v", p2)
149149
result.stdout.fnmatch_lines([
150-
"*test_p2.py::TestMore::test_p1* <- *test_p1.py*PASSED",
150+
"*test_p2.py::TestMore::test_p1* <- *test_p1.py*PASSED*",
151151
])
152152

153153
def test_itemreport_directclasses_not_shown_as_subclasses(self, testdir):

0 commit comments

Comments
 (0)