[Django] #25699: Allow using test client session handling with custom session apps

9 views
Skip to first unread message

Django

unread,
Nov 7, 2015, 9:33:43 AM11/7/15
to django-...@googlegroups.com
#25699: Allow using test client session handling with custom session apps
-----------------------------------+--------------------
Reporter: sergeykolosov | Owner: nobody
Type: Uncategorized | Status: new
Component: Testing framework | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+--------------------
This ticket follows up #22634 (which allowed extending database-backed
session backends).

While it is now possible to reuse session backend classes, it's not the
case for the corresponding parts of the test client.

Namely, in case of having the custom session backend and its corresponding
parts (models, middleware, etc) as a separate application, you're unable
to use the test client with sessions. The issue is
`'django.contrib.sessions'` being hardcoded inside of `_session` and
`login()`.

Working that around involves monkey-patching the test client with modified
copies of `_session` and `login()`.

I suggest refactoring test client for better reusability (given this would
eliminate session app name being hardcoded).

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

Django

unread,
Nov 7, 2015, 9:41:10 AM11/7/15
to django-...@googlegroups.com
#25699: Allow using test client session handling with custom session apps
-----------------------------------+--------------------------------------

Reporter: sergeykolosov | Owner: nobody
Type: Uncategorized | Status: new
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

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

* needs_better_patch: => 0
* has_patch: 0 => 1
* needs_tests: => 1
* needs_docs: => 0


Comment:

A possible solution in PR https://github.com/django/django/pull/5586

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

Django

unread,
Nov 7, 2015, 9:50:59 AM11/7/15
to django-...@googlegroups.com
#25699: Allow using test client session handling with custom session apps
-----------------------------------+------------------------------------

Reporter: sergeykolosov | Owner: nobody
Type: Uncategorized | Status: new
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

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

* stage: Unreviewed => Accepted


Comment:

I think that this is an useful thing to have.

I'm unsure about your PR on first sight, though, as it needs to add a new
setting for an edge case and adding settings is generally discouraged.
Maybe someone else likes to review it more thouroughly.

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

Django

unread,
Nov 7, 2015, 10:02:26 AM11/7/15
to django-...@googlegroups.com
#25699: Allow using test client session handling with custom session apps
-----------------------------------+------------------------------------

Reporter: sergeykolosov | Owner: nobody
Type: Uncategorized | Status: new
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-----------------------------------+------------------------------------

Comment (by claudep):

Instead of adding a new setting, I'd rather see an AppConfig attribute
(like `session_app`), and then the `_session_app_is_installed` could cycle
through installed AppConfig's to look for this attribute.

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

Django

unread,
Nov 7, 2015, 10:07:00 AM11/7/15
to django-...@googlegroups.com
#25699: Allow using test client session handling with custom session apps
-------------------------------------+-------------------------------------
Reporter: sergeykolosov | Owner:
| sergeykolosov
Type: Uncategorized | Status: assigned

Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 1

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

* owner: nobody => sergeykolosov
* needs_better_patch: 0 => 1
* status: new => assigned


Comment:

Sounds good, I'll update the PR given the suggested approach.

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

Django

unread,
Nov 10, 2015, 12:40:47 PM11/10/15
to django-...@googlegroups.com
#25699: Allow using test client session handling with custom session apps
-------------------------------------+-------------------------------------
Reporter: sergeykolosov | Owner:
| sergeykolosov
Type: New feature | Status: assigned

Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timgraham):

* type: Uncategorized => New feature


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

Django

unread,
Dec 4, 2015, 4:34:08 AM12/4/15
to django-...@googlegroups.com
#25699: Allow using test client session handling with custom session apps
-------------------------------------+-------------------------------------
Reporter: sergeykolosov | Owner:
| sergeykolosov
Type: New feature | Status: assigned
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by javins):

* cc: walt@… (added)


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

Django

unread,
Apr 1, 2016, 3:34:21 PM4/1/16
to django-...@googlegroups.com
#25699: Allow using test client session handling with custom session apps
-------------------------------------+-------------------------------------
Reporter: sergeykolosov | Owner:
| sergeykolosov
Type: New feature | Status: assigned
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by sergeykolosov):

I'm gonna work on solution suggested in
https://github.com/django/django/pull/5586#issuecomment-161918171

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

Django

unread,
Apr 2, 2016, 11:26:04 AM4/2/16
to django-...@googlegroups.com
#25699: Allow using test client session handling with custom session apps
-------------------------------------+-------------------------------------
Reporter: sergeykolosov | Owner:
| sergeykolosov
Type: New feature | Status: assigned
Component: Testing framework | Version: master
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 sergeykolosov):

* needs_better_patch: 1 => 0
* needs_tests: 1 => 0


Comment:

A new PR: https://github.com/django/django/pull/6380

--
Ticket URL: <https://code.djangoproject.com/ticket/25699#comment:8>

Django

unread,
Apr 2, 2016, 12:28:42 PM4/2/16
to django-...@googlegroups.com
#25699: Allow using test client session handling with custom session apps
-------------------------------------+-------------------------------------
Reporter: sergeykolosov | Owner:
| sergeykolosov
Type: New feature | Status: assigned
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

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

* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/25699#comment:9>

Django

unread,
Apr 3, 2016, 4:25:39 AM4/3/16
to django-...@googlegroups.com
#25699: Allow using test client session handling with custom session apps
-------------------------------------+-------------------------------------
Reporter: sergeykolosov | Owner:
| sergeykolosov
Type: New feature | Status: assigned
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by sergeykolosov):

PR updated: https://github.com/django/django/pull/6380

--
Ticket URL: <https://code.djangoproject.com/ticket/25699#comment:10>

Django

unread,
Apr 4, 2016, 7:58:37 AM4/4/16
to django-...@googlegroups.com
#25699: Allow using test client session handling with custom session apps
-------------------------------------+-------------------------------------
Reporter: sergeykolosov | Owner:
| sergeykolosov
Type: New feature | Status: closed

Component: Testing framework | Version: master
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

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


Comment:

In [changeset:"21dd98a38660747c781802afca7ca02407964383" 21dd98a3]:
{{{
#!CommitTicketReference repository=""
revision="21dd98a38660747c781802afca7ca02407964383"
Fixed #25699 -- Allowed using the test client if 'django.contrib.sessions'
isn't in INSTALLED_APPS.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/25699#comment:11>

Reply all
Reply to author
Forward
0 new messages