Last active
February 22, 2019 14:03
Star
You must be signed in to star a gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pytest | |
def checkHelper(value): | |
assert list(value) == list('foo') | |
@pytest.mark.parametrize("value", ( | |
'foo', | |
'far' | |
)) | |
def testInline(value): | |
assert list(value) == list('foo') | |
@pytest.mark.parametrize("value", ( | |
'foo', | |
'far' | |
)) | |
def testHelper(value): | |
checkHelper(value) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This compares reports from two cases of a simple test failure, using pytest 4.3.0. I am trying to work out how to get the same quality of failure reports, even in the case that I use a helper function.
In
testHelper()
the failing assertion is incheckHelper
in the same file. Pytest reports the failure poorly.In
testInline()
the identical failing assertion is inline in a test function. Pytest reports the failure well.I have found the low quality reports to be a blocker in real world cases, since the details of the failure are lost and the originating line cannot be navigated to.
Below is the report for
testHelper()
which relies on assertions taking place incheckHelper()
. The report has serious problems:>
the source of the error as being intestHelper()
, wherecheckHelper()
was called, not the line in checkHelper where the AssertionError was raised.assert
failureBy contrast, the case of
testInline()
gives me a much better report (except test_example.py:5 doesn't correspond with anything)Does anyone know how to get checkHelper to have its
assert
statements rewritten properly by pytest import hooks so it gets proper pytest failure reporting?