from mock import patch
from StringIO import StringIO

from geotrek.celery import debug_task

from django.test.testcases import TestCase


class CeleryTests(TestCase):
    @patch('sys.stdout', new_callable=StringIO)
    def test_debug_task(self, mocked_stdout):
        task = debug_task.s().apply(logfile='test_logfile')
        self.assertEqual(task.status, 'SUCCESS')
        self.assertIn('test_logfile', mocked_stdout.getvalue())

Add test global