Skip to content

self._outcome.errors no longer contains error data since pytest 5.4.0 #7000

@mdmintz

Description

@mdmintz

self._outcome.errors no longer contains error data since pytest 5.4.0

My test framework uses pytest to run tests that use a unittest.TestCase structure, and in the tearDown() method I was able to get error output from failing tests by using:
self._outcome.errors
This was working fine with pytest 5.3.5, but stopped working with pytest 5.4.0

This technique was made possible by this very popular solution on Stack Overflow: https://stackoverflow.com/a/39606065

Here's a code snippet that uses this technique to get the error from the tearDown() step when a test fails an assertion:

import unittest

class MyTest(unittest.TestCase):

    def tearDown(self):
        if hasattr(self, '_outcome'):
            errors = self._outcome.errors
            ...

I would like pytest to restore the use of self._outcome.errors so that tearDown() methods can easily access the error output of tests.
The test framework that I'm using (which I've built) is called SeleniumBase => https://github.com/seleniumbase/SeleniumBase
My workaround for now has been to hard-code pytest 5.3.5 into the requirements file for SeleniumBase. Given the large number of companies using SeleniumBase for test automation, I have to keep things working while waiting for a fix to arrive.

Metadata

Metadata

Assignees

No one assigned

    Labels

    plugin: unittestrelated to the unittest integration 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

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions