Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#15876 closed Bug (fixed)

Document that test.client.RequestFactory doesn't support sessions or request-altering middleware

Reported by: Paul Winkler Owned by: ShawnMilo
Component: Documentation Version: 1.3
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX:

Description

Since #15736 has been closed "wontfix", I think it could be classified as a documentation problem:
the RequestFactory docs at
http://docs.djangoproject.com/en/dev/topics/testing/#the-request-factory
make it sound like RequestFactory().get() creates a request that is equivalent to that used by TestClient.get().
But this is not true - TestClient goes out of its way to handle django.contrib.session, and loads middleware; RequestFactory does neither - and based on the response to #15736 that's by design.

So that should be explicit in the docs.

Attachments (1)

15876.diff (527 bytes) - added by ShawnMilo 5 years ago.
Documentation patch to make lack of middleware support explicit.

Download all attachments as: .zip

Change History (7)

comment:1 Changed 5 years ago by Jacob

Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset
Triage Stage: UnreviewedAccepted

Changed 5 years ago by ShawnMilo

Attachment: 15876.diff added

Documentation patch to make lack of middleware support explicit.

comment:2 Changed 5 years ago by ShawnMilo

Has patch: set

comment:3 Changed 5 years ago by Jacob

Triage Stage: AcceptedReady for checkin

comment:4 Changed 5 years ago by ShawnMilo

Owner: changed from nobody to ShawnMilo

comment:5 Changed 5 years ago by Tim Graham

Resolution: fixed
Status: newclosed

In [16128]:

Fixed #15876 - Document that test.client.RequestFactory doesn't support sessions or request-altering middleware; thanks slinkp for the suggestion, ShawnMilo for the patch.

comment:6 Changed 5 years ago by Tim Graham

In [16129]:

[1.3.X] Fixed #15876 - Document that test.client.RequestFactory doesn't support sessions or request-altering middleware; thanks slinkp for the suggestion, ShawnMilo for the patch.

Backport of r16128 from trunk.

Note: See TracTickets for help on using tickets.
Back to Top