Fix bad console output when using console_output_style=classic

Fix #3883
This commit is contained in:
Bruno Oliveira 2018-08-26 17:12:55 -03:00
parent a31967431f
commit 6991a16edb
3 changed files with 54 additions and 6 deletions

View File

@ -0,0 +1 @@
Fix bad console output when using ``console_output_style=classic``.

View File

@ -263,7 +263,7 @@ class TerminalReporter(object):
def write_fspath_result(self, nodeid, res):
fspath = self.config.rootdir.join(nodeid.split("::")[0])
if fspath != self.currentfspath:
if self.currentfspath is not None:
if self.currentfspath is not None and self._show_progress_info:
self._write_progress_information_filling_space()
self.currentfspath = fspath
fspath = self.startdir.bestrelpath(fspath)
@ -358,12 +358,12 @@ class TerminalReporter(object):
def pytest_runtest_logreport(self, report):
rep = report
res = self.config.hook.pytest_report_teststatus(report=rep)
cat, letter, word = res
category, letter, word = res
if isinstance(word, tuple):
word, markup = word
else:
markup = None
self.stats.setdefault(cat, []).append(rep)
self.stats.setdefault(category, []).append(rep)
self._tests_ran = True
if not letter and not word:
# probably passed setup/teardown

View File

@ -3,6 +3,7 @@ terminal reporting of the full testing process.
"""
from __future__ import absolute_import, division, print_function
import collections
import os
import sys
import textwrap
@ -472,7 +473,7 @@ class TestTerminalFunctional(object):
def test_show_deselected_items_using_markexpr_before_test_execution(self, testdir):
testdir.makepyfile(
"""
test_show_deselected="""
import pytest
@pytest.mark.foo
@ -491,7 +492,7 @@ class TestTerminalFunctional(object):
result.stdout.fnmatch_lines(
[
"collected 3 items / 1 deselected",
"*test_show_des*.py ..*",
"*test_show_deselected.py ..*",
"*= 2 passed, 1 deselected in * =*",
]
)
@ -1134,7 +1135,53 @@ def test_no_trailing_whitespace_after_inifile_word(testdir):
assert "inifile: tox.ini\n" in result.stdout.str()
class TestProgress(object):
class TestClassicOutputStyle(object):
"""Ensure classic output style works as expected (#3883)"""
@pytest.fixture
def test_files(self, testdir):
testdir.makepyfile(
**{
"test_one.py": "def test_one(): pass",
"test_two.py": "def test_two(): assert 0",
"sub/test_three.py": """
def test_three_1(): pass
def test_three_2(): assert 0
def test_three_3(): pass
""",
}
)
def test_normal_verbosity(self, testdir, test_files):
result = testdir.runpytest("-o", "console_output_style=classic")
result.stdout.fnmatch_lines(
[
"test_one.py .",
"test_two.py F",
"sub{}test_three.py .F.".format(os.sep),
"*2 failed, 3 passed in*",
]
)
def test_verbose(self, testdir, test_files):
result = testdir.runpytest("-o", "console_output_style=classic", "-v")
result.stdout.fnmatch_lines(
[
"test_one.py::test_one PASSED",
"test_two.py::test_two FAILED",
"sub{}test_three.py::test_three_1 PASSED".format(os.sep),
"sub{}test_three.py::test_three_2 FAILED".format(os.sep),
"sub{}test_three.py::test_three_3 PASSED".format(os.sep),
"*2 failed, 3 passed in*",
]
)
def test_quiet(self, testdir, test_files):
result = testdir.runpytest("-o", "console_output_style=classic", "-q")
result.stdout.fnmatch_lines([".F.F.", "*2 failed, 3 passed in*"])
class TestProgressOutputStyle(object):
@pytest.fixture
def many_tests_files(self, testdir):
testdir.makepyfile(