Fix regression where functions registered with ``TestCase.addCleanup`` were not being called on test failures.