[Django] #33026: The Testing Tools docs should highlight RequestFactory

1 view
Skip to first unread message

Django

unread,
Aug 14, 2021, 11:32:06 AM8/14/21
to django-...@googlegroups.com
#33026: The Testing Tools docs should highlight RequestFactory
-----------------------------------------+------------------------
Reporter: Roy Smith | Owner: nobody
Type: Uncategorized | Status: new
Component: Documentation | Version: 3.2
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 |
-----------------------------------------+------------------------
I've used django.test.Client for several large projects over the years.
Recently, I got stuck because I couldn't get session management to work in
my tests. Judging from the number of StackOverflow, etc, posts on this
topic, this is a common issue. Eventually I found
https://stackoverflow.com/questions/25132621/ which put me onto using
RequestFactory instead of the Test Client. I'm sure I'd seen
RequestFactory mentioned before, but never explored it.

I think RequestFactory should be emphasized more in
https://docs.djangoproject.com/en/3.1/topics/testing/tools/. Right now,
the only mention is buried deep down on the page in a "See also" box which
links to the "Advanced testing topics". Labeling it as an "advanced"
topic is misleading. ​May I suggest that it should be at least briefly
covered in the introductory section. There's already a couple of
paragraphs contrasting django.test.client to Selenium. It would be good
to say something like:

A lower-level alternative to the test client is RequestFactory, which lets
you bypass the routing and middleware layers. Use RequestFactory to write
unit tests of individual view functions and methods. Use the test client
to write integration tests of how your views work in the context of your
full application. Use Selenium to test rendered HTML and the behavior of
Web pages, namely JavaScript functionality.

I'd be happy to write up an improved doc if you think this is a reasonable
way to go.

--
Ticket URL: <https://code.djangoproject.com/ticket/33026>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Aug 17, 2021, 4:17:35 AM8/17/21
to django-...@googlegroups.com
#33026: The Testing Tools docs should highlight RequestFactory
--------------------------------------+------------------------------------

Reporter: Roy Smith | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Documentation | Version: 3.2
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by Carlton Gibson):

* type: Uncategorized => Cleanup/optimization
* stage: Unreviewed => Accepted


Comment:

Hey Roy, OK — very happy to look at a suggestion here. Thanks.

--
Ticket URL: <https://code.djangoproject.com/ticket/33026#comment:1>

Django

unread,
Sep 24, 2022, 5:53:51 AM9/24/22
to django-...@googlegroups.com
#33026: The Testing Tools docs should highlight RequestFactory
-------------------------------------+-------------------------------------
Reporter: Roy Smith | Owner: Chris
Type: | Wedgwood
Cleanup/optimization | Status: assigned
Component: Documentation | Version: 3.2

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Chris Wedgwood):

* owner: nobody => Chris Wedgwood
* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/33026#comment:2>

Django

unread,
Sep 24, 2022, 6:43:20 AM9/24/22
to django-...@googlegroups.com
#33026: The Testing Tools docs should highlight RequestFactory
-------------------------------------+-------------------------------------
Reporter: Roy Smith | Owner: Chris
Type: | Wedgwood
Cleanup/optimization | Status: assigned
Component: Documentation | Version: 3.2

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Chris Wedgwood):

* has_patch: 0 => 1


Comment:

https://github.com/django/django/pull/16094

--
Ticket URL: <https://code.djangoproject.com/ticket/33026#comment:3>

Django

unread,
Sep 26, 2022, 6:15:20 AM9/26/22
to django-...@googlegroups.com
#33026: The Testing Tools docs should highlight RequestFactory
-------------------------------------+-------------------------------------
Reporter: Roy Smith | Owner: Chris
Type: | Wedgwood
Cleanup/optimization | Status: assigned
Component: Documentation | Version: 3.2

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* needs_better_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/33026#comment:4>

Django

unread,
Sep 26, 2022, 7:55:47 AM9/26/22
to django-...@googlegroups.com
#33026: The Testing Tools docs should highlight RequestFactory
-------------------------------------+-------------------------------------
Reporter: Roy Smith | Owner: Chris
Type: | Wedgwood
Cleanup/optimization | Status: assigned
Component: Documentation | Version: 3.2

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Chris Wedgwood):

* needs_better_patch: 1 => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/33026#comment:5>

Django

unread,
Sep 28, 2022, 11:59:07 PM9/28/22
to django-...@googlegroups.com
#33026: The Testing Tools docs should highlight RequestFactory
-------------------------------------+-------------------------------------
Reporter: Roy Smith | Owner: Chris
Type: | Wedgwood
Cleanup/optimization | Status: closed
Component: Documentation | Version: 3.2
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by GitHub <noreply@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"468d06109778e3656229ac28c9019ea7246f9b79" 468d0610]:
{{{
#!CommitTicketReference repository=""
revision="468d06109778e3656229ac28c9019ea7246f9b79"
Fixed #33026 -- Mentioned RequestFactory in testing tools docs.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/33026#comment:6>

Django

unread,
Sep 29, 2022, 12:01:44 AM9/29/22
to django-...@googlegroups.com
#33026: The Testing Tools docs should highlight RequestFactory
-------------------------------------+-------------------------------------
Reporter: Roy Smith | Owner: Chris
Type: | Wedgwood
Cleanup/optimization | Status: closed
Component: Documentation | Version: 3.2

Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak <felisiak.mariusz@…>):

In [changeset:"7607fc8990ec61b51d4a3baf0be51c28fa5f4605" 7607fc89]:
{{{
#!CommitTicketReference repository=""
revision="7607fc8990ec61b51d4a3baf0be51c28fa5f4605"
[4.1.x] Fixed #33026 -- Mentioned RequestFactory in testing tools docs.

Backport of 468d06109778e3656229ac28c9019ea7246f9b79 from main
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/33026#comment:7>

Reply all
Reply to author
Forward
0 new messages