Beispiel #1
0
 def tearDown(self):
     # remove instrumentation from Celery
     unpatch()
     self.app = None
     # restore the global configuration
     config.celery.update(self._config)
     self._config = None
Beispiel #2
0
    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)
Beispiel #3
0
    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)
Beispiel #4
0
    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))
Beispiel #5
0
 def instrument_celery(self):
     # instrument Celery and create an app with Broker and Result backends
     patch()
     yield
     # remove instrumentation from Celery
     unpatch()
Beispiel #6
0
    def tearDown(self):
        # remove instrumentation from Celery
        unpatch()
        self.app = None

        super(CeleryBaseTestCase, self).tearDown()
Beispiel #7
0
 def tearDown(self):
     # be sure the system is always unpatched
     unpatch()
     self.app = None