I'm seeing that assertion messages do not seem to be displayed if the assertion occurs in a helper method within the same module as my test when in PyCharm.
This only seems to be happening in PyCharm - it does not happen when running from the command line.
This works:
def test_assertion_message_working():
assert 1 == 2, "my message"
Expected :2
Actual :1
...
def test_assertion_message_working():
> assert 1 ==2, "my message"
But this doesn't (the test fails, but I do not get the failure message):
def test_assertion_message_not_working():
do_assertion()
def do_assertion():
assert 1 == 2, "my message"
1 != 2
Expected :2
Actual :1
...
def test_assertion_not_working():
> do_assertion()
Wondering if there is any setting (or workaround) I need to apply to get this working?
Add the next additional flag to the run configuration Additional Arguments: --tb=short
You can edit the configuration templates to make it the default.
More info can be found here: https://youtrack.jetbrains.com/issue/PY-49150/pytest-output-in-PyCharm-lacks-information-about-assertion-failures-in-helper-methods

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With