check_assertions usage
Hi there,
first off, thank you for the great project!
I have run into an issue multiple times and I am wondering if I am using the plugin wrong.
When writing tests or refactoring I ran into situations where the test fails because the server response with a 500 - which makes my test fail before I could call check_assetions. So nothing is logged or raised to provide any guidance what when wrong.
I solved it by having a patched version of the plugin which writes logs on any failed match.
How is it supposed to work?
Hi there,
The problem here is that the server is running in a different thread, so it cannot raise an exception in the other. I consider printing out to stderr is an anti-pattern as it is difficult to avoid the printing, however it may be good to add an option for the library to enable printing.
Anyway, in my tests, when I have this issue, I usually wrap the whole test into try..finally block, and in the finally block, I call the check assertions method.
I haven't tried it, but you may try to create a fixture which calls it when there was an error:
def httpserver_debug(httpserver):
try:
yield httpserver
finally:
httpserver.check()
Then, in your test you can use httpserver_debug. If the naming is inconvenient for you, you can also do:
def httpserver(httpserver):
[...]
To override the fixture.
Could you give it a try?
I'll also look at how to enable the debug printing depending on an envvar or command line arg.