def test_unpatch_task(self): """ When unpatch_task is called on a patched task we unpatch the __init__, apply, apply_async, and run methods """ # Assert base class methods are patched self.assertIsInstance(celery.Task.__init__, wrapt.BoundFunctionWrapper) self.assertIsInstance(celery.Task.apply, wrapt.BoundFunctionWrapper) self.assertIsInstance(celery.Task.apply_async, wrapt.BoundFunctionWrapper) self.assertIsInstance(celery.Task.run, wrapt.BoundFunctionWrapper) # Unpatch the base class unpatch_task(celery.Task) # Assert the methods are no longer wrapper self.assertFalse(isinstance(celery.Task.__init__, wrapt.BoundFunctionWrapper)) self.assertFalse(isinstance(celery.Task.apply, wrapt.BoundFunctionWrapper)) self.assertFalse(isinstance(celery.Task.apply_async, wrapt.BoundFunctionWrapper)) self.assertFalse(isinstance(celery.Task.run, wrapt.BoundFunctionWrapper))
def tearDown(self): unpatch_app(celery.Celery) unpatch_task(celery.Task)