#32409: TestCase async tests are not transaction-aware
-------------------------------------+-------------------------------------
               Reporter:  David      |          Owner:  nobody
                   Type:  Bug        |         Status:  new
              Component:  Testing    |        Version:  3.1
  framework                          |       Keywords:  TestCase, async,
               Severity:  Normal     |  transaction
           Triage Stage:             |      Has patch:  0
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  0
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 `SimpleTestCase` wraps each ''async'' test with `async_to_sync` (see
 
[https://github.com/django/django/commit/17009e910538b9c3709d302f54c2d10eb245cf38
 commit]).

 When using `TestCase` this results in problems while accessing the
 database via `sync_to_async` (or with channels `database_sync_to_async`).
 Since under-the-hood `aync_to_sync` runs the async code in an other thread
 and savepoints (aka: transactions) are thread-bound what happens is that
 those tests do not interact with the actual ("expected") database which is
 wrapped in a transaction bound to main thread.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/32409>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/049.14f6753f9df335224966647cc75c3cbe%40djangoproject.com.

Reply via email to