mardi 30 mai 2017

Handle same Python exception for all tests in test class

Similar to a setUp() method, is there a way to define in one place how a certain exception is handled for all the tests in a given TestCase test class?

My use-case: the stack trace of mock/patch's assert_any_call only gives the expected call it could not find, but I want to add the actual calls against the mock. Each unit test can add this info to the stack trace in an except clause, but I want it defined in one place to avoid bloated code.

Aucun commentaire:

Enregistrer un commentaire