'Test celery task with django

I´m trying test a celery task in my django project using the same database as django test. In my setup I have

databases = '__all__'

@classmethod
def setUpClass(cls):
    super().setUpClass()

    # Start up celery worker
    cls.celery_worker = start_worker(app, perform_ping_check=False)
    cls.celery_worker.__enter__()

@classmethod
def tearDownClass(cls):
    super().tearDownClass()

    # Close worker
    cls.celery_worker.__exit__(None, None, None)

But i got psycopg2.InterfaceError: connection already closed when run cls.celery_worker.enter().

Somebody can help me?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source