#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 | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
---------------------------------------------+------------------------
Currently, when [https://docs.djangoproject.com/en/dev/ref/settings
/#atomic-requests ATOMIC_REQUESTS] is `True`, actions scheduled with the
[https://docs.djangoproject.com/en/dev/topics/db/transactions/#performing-
actions-after-commit on_commit] hook are not run by the test `Client`.
Commit hooks can be run manually, e.g. by subclassing Django’s test
`Client` and running the hooks after the parent’s `request()`generated the
response. However, it makes a difference with real-world requests, for
which hooks run before the middleware chain processes the response.
The `ClientHandler` defined in `django/test/client.py` is private and the
`Client` does not offer to override its handler (except by subclassing the
view and forcefully setting the handler attribute to a customized handler
instance.
Maybe the default test `ClientHandler` should override
`make_view_atomic()` to run `on_commit` hooks right after the view
function is executed?
--
Ticket URL: <https://code.djangoproject.com/ticket/31281>
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/058.fe4a789789c70acfded813de8f504689%40djangoproject.com.