Opened 12 years ago
Closed 11 years ago
#18356 closed Bug (fixed)
Test Client response does not contain Context with nested requests
Reported by: | bmihelac | Owned by: | nobody |
---|---|---|---|
Component: | Testing framework | Version: | 1.4 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
get() and post() methods returns Response object, including context
variable that was used to render the template that produced the response content.
However, if view calls another view before returning response, processing nested view will disconnect template_rendered
signal returning no Context object.
I am attaching failing test case.
Attachments (1)
Change History (8)
by , 12 years ago
Attachment: | 18356-test-client-context-lost-for-nested-views.diff added |
---|
comment:1 by , 12 years ago
comment:2 by , 12 years ago
Fix for this can be in giving dispatch_uid unique value for each request. This is added to branch and pull request if there are no objections.
comment:3 by , 12 years ago
Triage Stage: | Unreviewed → Design decision needed |
---|---|
Type: | Uncategorized → Bug |
Well, the test client wasn't designed to be used from within a view.
Could you show us the patch that would fix this problem?
follow-up: 5 comment:4 by , 12 years ago
Changeset that fixes this issue is:
https://github.com/bmihelac/django-1/commit/86a374e4d149b9a11aedc69753ce91b46669d16e
(branch has test case and fix)
BTW, i found this issue while trying to fix django-test-utils, which has middleware that records context for every request made. Testing that necessarily leads to nesting requests in a test case.
comment:6 by , 12 years ago
Triage Stage: | Design decision needed → Accepted |
---|
This is quite an edge case, but I can't see any downside to the fix.
comment:7 by , 11 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Failing test is in my github branch:
https://github.com/bmihelac/django-1/tree/18356-test-client-context-lost-for-nested-views