[Django]-Saving to database in Django tests when using ThreadPoolExecutor

0👍

This worked for me. Put your test in this structure:

from django.test import TransactionTestCase

class AsyncTestCase(TransactionTestCase):

    def test_my_code(self):
        ...

This keeps the data in memory and doesn’t do a commit to the database. I’m guessing that the threaded code uses a different database connection during tests.

👤Joep

Leave a comment