Skip to content

References to tests in === FAILURES === report should be suitable as input to select tests. #3546

@TauPan

Description

@TauPan

Hi!

I'd like to be able to quickly retest a certain failing test after running the whole suite. --last-failed provides a similar functionality, but not the same if multiple (or many) tests fail.

Whenever I have failures, the "FAILED/PASSED" lines in the session report lists them in a way that is suitable for input for selecting them for a subsequent run (as outlined in https://docs.pytest.org/en/latest/usage.html#specifying-tests-selecting-tests).

project/package/tests/test_or.py::TestSomeClass::test_some_behaviour FAILED  [  1%]

However when I'm investigating a failure I'm often looking at the backtrace and variables in the === FAILURES === section of pytest's output:

============================================== FAILURES ==============================================
___________________________ TestSomeClass.test_some_behaviour ____________________________

self = <project.package.tests.test_or.TestSomeClass testMethod=test_some_behaviour>

    def test_some_behaviour(self):
[...]
self       = <project.package.tests.test_or.TestSomeClass testMethod=test_some_behaviour>

project/package/tests/test_or.py:158: AssertionError

And to get the node id of the test in question, I either have to scroll up (quite far, if my testsuite contains over 500 tests) or piece the information together from the output.

I can use the method name test_some_behaviour together with -k but this might execute multiple tests with the same name.

In the concrete example it would be convenient for me if project/package/tests/test_or.py::TestSomeClass::test_some_behaviour would appear somewhere in the FAILURES output.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: needs informationreporter needs to provide more information; can be closed after 2 or more weeks of inactivitytopic: reportingrelated to terminal output and user-facing messages and errorstype: questiongeneral question, might be closed after 2 weeks of inactivity

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions