Hi Shawn, Shawn Brown <03sjbr...@gmail.com> writes:
> I understand how to use pytest_assertrepr_compare() to return custom > assertion reports--but this interface requires a comparison operator. I'm > hoping to write a plugin that makes custom reports for statements like: > > assert myfunc(myobj) > > Where myfunc() returns True or False. But without an operator (e.g. "=="), > I can't intercept the results to build my custom report. After refreshing my mind on the AST-rewriting code again -that's always tricky- I think you have been looking into the wrong direction. I believe something as simple as this might do: def test_foo(): assert myfunc(42) def myfunc(*args): __tracebackhide__ if not args: pytest.fail('Hello there\nLook, a multi-line message') raise AssertionError('multi\nline') # alternative, never gets here return True Does this solve your usecase? Cheers, Floris _______________________________________________ pytest-dev mailing list pytest-dev@python.org https://mail.python.org/mailman/listinfo/pytest-dev