Re: [Django] #31281: Make TestClient run transaction.on_commit actions.

2020-02-18 Thread Django
#31281: Make TestClient run transaction.on_commit actions.
---+--
 Reporter:  François Freitag   |Owner:  nobody
 Type:  New feature|   Status:  closed
Component:  Testing framework  |  Version:  master
 Severity:  Normal |   Resolution:  duplicate
 Keywords: | Triage Stage:  Unreviewed
Has patch:  0  |  Needs documentation:  0
  Needs tests:  0  |  Patch needs improvement:  0
Easy pickings:  0  |UI/UX:  0
---+--

Comment (by François Freitag):

 Many thanks for the detailed explanation and the triage.

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/073.adc294090584cd260e52ed8c274ea2c8%40djangoproject.com.


Re: [Django] #31281: Make TestClient run transaction.on_commit actions. (was: Make TestClient run transaction.on_commit actions)

2020-02-17 Thread Django
#31281: Make TestClient run transaction.on_commit actions.
---+--
 Reporter:  François Freitag   |Owner:  nobody
 Type:  New feature|   Status:  closed
Component:  Testing framework  |  Version:  master
 Severity:  Normal |   Resolution:  duplicate
 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 felixxm):

 * status:  new => closed
 * resolution:   => duplicate


Comment:

 I agree with Simon, this can be treated as a duplicate of #30457.

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/073.d5563439d09f24f61be5feda7975d609%40djangoproject.com.


Re: [Django] #31281: Make TestClient run transaction.on_commit actions

2020-02-17 Thread Django
#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: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/073.40c415016b82e9696fd59448942a1f43%40djangoproject.com.


[Django] #31281: Make TestClient run transaction.on_commit actions

2020-02-17 Thread Django
#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: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/058.fe4a789789c70acfded813de8f504689%40djangoproject.com.