pytest-assume
pytest-assume copied to clipboard
Display expected and actual for failed assumes
Is there any way for each failed assume to display what was expected and what the actual result was?
That was my original goal when I was working on this, but it's not really feasible unless I use what pytest itself does with assertions. They re-write the modules, breaking down each assert into parts for use with display, then asserting. You can see some of that here, and it's really not an easy thing to replicate (or reuse).
Ok thanks, it's a shame, but appreciate you have made the effort to investigate.
_pytest.assertion.rewrite seems to have moved since @astraw38 linked to it in January 2017.
Updated location: https://github.com/pytest-dev/pytest/blob/3.8.2/src/_pytest/assertion/rewrite.py (with a tagged release, rather than off the master, which could be subject to the same problem in the future)
@mcarans using assume as a context manager retains the pytest generated explanations, as you will still be having the assert
keyword and those will naturally be rewritten by pytest.
@Sup3rGeo Do you mean use this form:
with assume: assert x == y
with assume: assert True
with assume: assert False
?
Yes!