Opened 9 years ago
Closed 9 years ago
#25699 closed New feature (fixed)
Allow using test client session handling with custom session apps
Reported by: | Sergey Kolosov | Owned by: | Sergey Kolosov |
---|---|---|---|
Component: | Testing framework | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | walt@… | Triage Stage: | Ready for checkin |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
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).
Change History (11)
comment:1 by , 9 years ago
Has patch: | set |
---|---|
Needs tests: | set |
comment:2 by , 9 years ago
Triage Stage: | Unreviewed → Accepted |
---|
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.
comment:3 by , 9 years ago
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.
comment:4 by , 9 years ago
Owner: | changed from | to
---|---|
Patch needs improvement: | set |
Status: | new → assigned |
Sounds good, I'll update the PR given the suggested approach.
comment:5 by , 9 years ago
Type: | Uncategorized → New feature |
---|
comment:6 by , 9 years ago
Cc: | added |
---|
comment:7 by , 9 years ago
I'm gonna work on solution suggested in https://github.com/django/django/pull/5586#issuecomment-161918171
comment:8 by , 9 years ago
Needs tests: | unset |
---|---|
Patch needs improvement: | unset |
comment:9 by , 9 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
A possible solution in PR https://github.com/django/django/pull/5586