Recently, Ned Batchelder during his talk at PyCon 2016 noted:
If you are usingto write your tests, definitely use
, it's much better than
addCleanup doc string:
Cleanup items are called even if setUp fails (unlike tearDown)
addCleanup can be used to register multiple functions, so you could use
separate functions for each resource you wish to clean up. That would allow your
code to be a bit more reusable/modular.