def tearDown(self): # remove instrumentation from Celery unpatch() self.app = None # restore the global configuration config.celery.update(self._config) self._config = None
def instrument_celery(self): # Register our context-ruining signal before the normal ones so that # the "real" task_prerun signal starts with the new context celery.signals.task_prerun.connect(self.inject_new_context) # instrument Celery and create an app with Broker and Result backends patch() yield # remove instrumentation from Celery unpatch() celery.signals.task_prerun.disconnect(self.inject_new_context)
def test_idempotent_unpatch(self): # calling unpatch() twice doesn't have side effects unpatch() unpatch() @self.app.task def fn_task(): return 42 t = fn_task.apply() assert t.successful() assert 42 == t.result traces = self.pop_traces() assert 0 == len(traces)
def test_idempotent_unpatch(self): # calling unpatch() twice doesn't have side effects unpatch() unpatch() @self.app.task def fn_task(): return 42 t = fn_task.apply() ok_(t.successful()) eq_(42, t.result) traces = self.tracer.writer.pop_traces() eq_(0, len(traces))
def instrument_celery(self): # instrument Celery and create an app with Broker and Result backends patch() yield # remove instrumentation from Celery unpatch()
def tearDown(self): # remove instrumentation from Celery unpatch() self.app = None super(CeleryBaseTestCase, self).tearDown()
def tearDown(self): # be sure the system is always unpatched unpatch() self.app = None