jeudi 1 janvier 2015

py.test: dump stuck background threads at the end of the tests

I am using pytest to run my projects Python unit tests.


For some reason, sometimes the test runner does not exist after printing the test stats. I suspect this is because some tests open background threads and some dangling threads are not cleaned up properly in the tear down. As this does not occur every time, it makes it harder to pin down what is exactly happening.


I am hoping to find a way to make pytest to display what threads after it prints failed and passed tests. Some ideas I came up with?




  • Run custom hook after tests are finished - does py.test support any of such hooks?




  • Some other way (custom py.test wrapping script)




Other alternative ways I think would be just print thread dump at the end of each tear down.


Python 3.4.


Aucun commentaire:

Enregistrer un commentaire