Skip to content

5.3 changes plurality of keys in testdir.run().parseoutcomes() #6505

@altendky

Description

@altendky

While testdir.run().parseoutcomes() used to give results such as {'warnings': 1} (plural) it now gives {'warning': 1} (singular). This broke the tests in pytest-twisted... and while I setup nightly 'cron' builds I apparently didn't bother to notice when they broke awhile ago. :[ I do not know what the proper answer is here especially now that we have multiple versions out with each approach. Since pytest-twisted is still supporting py2, I don't get to just update to latest pytest functionality across the board. Though yes, py2 support will at some point be dropped when the pain is sufficient.

I'll just normalize the parseoutcomes() dict keys myself but wanted to document the change and see what opinions there are on it.

When pytest-twisted broke:
last good pytest==5.2.4: https://travis-ci.org/pytest-dev/pytest-twisted/jobs/614201584
first bad pytest==5.3.0: https://travis-ci.org/pytest-dev/pytest-twisted/jobs/614718766

Introduced in #5989 and d863c30.

There seems to be little testing being done on parseoutcomes().

def test_testdir_outcomes_with_multiple_errors(testdir):
p1 = testdir.makepyfile(
"""
import pytest
@pytest.fixture
def bad_fixture():
raise Exception("bad")
def test_error1(bad_fixture):
pass
def test_error2(bad_fixture):
pass
"""
)
result = testdir.runpytest(str(p1))
result.assert_outcomes(error=2)
assert result.parseoutcomes() == {"error": 2}

pytest/testing/test_capture.py

Lines 1161 to 1191 in e98176c

def test_stdcapture_fd_invalid_fd(self, testdir):
testdir.makepyfile(
"""
import os
from _pytest import capture
def StdCaptureFD(out=True, err=True, in_=True):
return capture.MultiCapture(out, err, in_, Capture=capture.FDCapture)
def test_stdout():
os.close(1)
cap = StdCaptureFD(out=True, err=False, in_=False)
assert repr(cap.out) == "<FDCapture 1 oldfd=None _state=None>"
cap.stop_capturing()
def test_stderr():
os.close(2)
cap = StdCaptureFD(out=False, err=True, in_=False)
assert repr(cap.err) == "<FDCapture 2 oldfd=None _state=None>"
cap.stop_capturing()
def test_stdin():
os.close(0)
cap = StdCaptureFD(out=False, err=False, in_=True)
assert repr(cap.in_) == "<FDCapture 0 oldfd=None _state=None>"
cap.stop_capturing()
"""
)
result = testdir.runpytest_subprocess("--capture=fd")
assert result.ret == 0
assert result.parseoutcomes()["passed"] == 3

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueeasy issue that is friendly to new contributorplugin: pytesterrelated to the pytester builtin plugintype: bugproblem that needs to be addressedtype: regressionindicates a problem that was introduced in a release which was working previously

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions