[pytest-dev] Displaying additional test failure information
Jurko Gospodnetić
jurko.gospodnetic at pke.hr
Sun Mar 2 23:36:56 CET 2014
Hi all.
I was wondering if anyone can tell me the cleanest way to make
assertions in a specific part of my test code (e.g. a specific test
class or module) report some extra information on test failure?
I can add a regular assertion description string, and that displays
the extra information but it also avoids regular pytest test failure
result reporting which I would like to keep.
I can also print out the extra information directly to stdout/stderr
- but that can be hard to read, especially if the test prints out other
data as well.
Usage scenario:
---------------
Imagine a class for comparing two XML structures. That class
maintains some context information that would be useful to print out
when an XML mismatch is detected. For example, if it detects two nodes
with different namespaces, you want it to:
- report exactly which nodes these are and not just 'there exist two
nodes with mismatched namespaces'
- make this information available without the developer having to
drop into the debugger
If possible, it would also be a great plus if this extra content
could be integrated into the regular 'red' assertion failure information.
Best regards,
Jurko Gospodnetić
More information about the Pytest-dev
mailing list