#32409: TestCase async tests are not transaction-aware
-------------------------------------+-------------------------------------
     Reporter:  David                |                    Owner:  nobody
         Type:  New feature          |                   Status:  new
    Component:  Testing framework    |                  Version:  3.1
     Severity:  Normal               |               Resolution:
     Keywords:  TestCase, async,     |             Triage Stage:  Accepted
  transaction                        |
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by David):

 I have added thead-id logging to my test app and unittests.

 Looking at [https://github.com/sevdog/test-websocker-user-
 
lock/blob/8a953b19ec3c0725cf336df93b1d5c7644965041/ws_lock/tests/test_with_django.py#L18
 connect test] It seems that in some way with django `TestCase` an extra
 thread gets spawned.



 {{{
 test-setup 140537656747840
 test 140537592018688
 db-connection-2 140537583625984
 --- error gets thrown
 }}}

 While the [https://github.com/sevdog/test-websocker-user-
 
lock/blob/8a953b19ec3c0725cf336df93b1d5c7644965041/ws_lock/tests/test_with_pytest.py#L9
 corresponding test] with pytest does not.

 {{{
 fixture-sync 140584466261824
 fixture-sync 140584466261824
 fixture-async 140584466261824
 db-connection-2 140584401794816
 connect 140584466261824
 db-connection-1 140584401794816
 test 140584466261824
 db-connection-4 140584401794816
 disconnect 140584466261824
 --- test successfull
 }}}

 I checked against the test case provided by Carlton and seems that it
 passes with `asgiref==3.3.1`. I do not know if `ApplicationCommunicator`
 from `asgiref` are bound in some way to this issue.

 I will investigate were the source of the problem lies and create an
 appropriate test case for it.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/32409#comment:12>
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/064.0fbc42700bb4abeeba910c2ba326baf6%40djangoproject.com.

Reply via email to