#32409: TestCase async tests are not transaction-aware
-------------------------------------+-------------------------------------
Reporter: David | Owner: KangDo96
Type: New feature | Status: assigned
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 Aleksi Hoffman):
I'm faced with a similar {{{OperationalError}}} whilst testing an async
middleware using {{{TestCase}}}.
The db accessing method in the middleware is decorated with {{{
@database_sync_to_async }}} from Channels. Package versions are
{{{django==3.2.8}}} {{{channels==3.0.4}}}, {{{ asgiref==3.4.1 }}} and
{{{pytest==6.2.5}}}.
Decorating the async test case with both {{{@pytest.mark.asyncio}}} and
{{{@async_to_sync}}} seems to make the problem go away.
--
Ticket URL: <https://code.djangoproject.com/ticket/32409#comment:19>
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.8cfe50e43a6f3eb1838e6a338a675e99%40djangoproject.com.