#31281: Make TestClient run transaction.on_commit actions
-----------------------------------+--------------------------------------
Reporter: François Freitag | Owner: nobody
Type: New feature | Status: new
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+--------------------------------------
Changes (by Simon Charette):
* cc: Simon Charette (added)
Comment:
This is a common pitfall (#30601) and closely related or maybe a dupe of
#30457.
Only changing the behavior of the test `Client` to perform such operation
would be tricky because of the following setup.
{{{#!python
def test_atomic_view(self):
def receiver():
pass
transaction.on_commit(receiver)
client.post('/atomic_view')
}}}
Would you expect `receiver` to be called or not? I think it could be
considered unexpected behaviour in both cases.
I think we need a solution akind to the `execute_on_commit`
[https://code.djangoproject.com/ticket/30457#comment:10 context manager]
with `RuntimeWarning` when `transacition.on_commit` is used without
''mocking'' within the context of a `TestCase`.
--
Ticket URL: <https://code.djangoproject.com/ticket/31281#comment:1>
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/073.40c415016b82e9696fd59448942a1f43%40djangoproject.com.