def tearDown(self): try: description_of_hooks = "\n".join( gen_description_of_hooks(post_commit_hooks.hooks)) self.expectThat( post_commit_hooks.hooks, HasLength(0), "One or more post-commit tasks were present at the end of " "this test.\n" + description_of_hooks) super(PostCommitHooksTestMixin, self).tearDown() finally: # By this point we will have reported the leaked post-commit # tasks, so always reset them; we don't want to report them again, # and we don't want to execute them. post_commit_hooks.reset()
def setUp(self): try: super(PostCommitHooksTestMixin, self).setUp() description_of_hooks = "\n".join( gen_description_of_hooks(post_commit_hooks.hooks)) self.expectThat( post_commit_hooks.hooks, HasLength(0), "One or more post-commit tasks were present before " "commencing this test:\n" + description_of_hooks) finally: # By this point we will have reported the leaked post-commit # tasks, so always reset them; we don't want to report them again, # and we don't want to execute them. post_commit_hooks.reset()