def setUp(self): """ Remember the current state, then reset """ self.was_patched = unpatch() self.unpatch_all() self.addCleanup(self.cleanup)
def setUp(self): """ Remember the current state, then reset """ super(MonkeyPatchTest, self).setUp() self.was_patched = unpatch() self.unpatch_all() self.addCleanup(self.cleanup)
def test_patch(self): """ Test that `self._` correctly translates text before, during, and after being monkey-patched. """ self.assert_translations() was_successful = patch() self.assertTrue(was_successful) self.assert_translations() was_successful = unpatch() self.assertTrue(was_successful) self.assert_translations()
def unpatch_all(self): """ Unpatch the module recursively """ while is_patched(): unpatch()