Opened 14 years ago

Closed 14 years ago

Last modified 14 years ago

#12720 closed (fixed)

Django test client cookie handling broken with Python trunk and next 2.6.$NEXT

Reported by: James Henstridge Owned by: nobody
Component: Testing framework Version: 1.1
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

After upgrading to the the Ubuntu 10.04 alpha, I found that the tests for my Django application started failing. This seemed to be because the Python 2.6 package included unreleased fixes from the release26-maint branch. In particular it included the following bug fix to the Cookie module:

http://bugs.python.org/issue5275

When the django.test client builds up a WSGI environment, it passes a SimpleCookie instance for HTTP_COOKIE. Prior to the change, django.http.parse_cookie() would copy the morsels directly. After the change, the values for all the cookies are the str() version of the morsels (e.g. "Set-Cookie: sessionid=value" instead of "value").

This breaks any tests that depend on cookie handling (e.g. those that depend on cookie authentication).

While this does represent a change of behaviour in Python, the behaviour of the django test client does not really match the WSGI specification in this regard, so I think it'd be worth fixing in Django. Patch attached.

Attachments (1)

django-test-client-cookie-fix.patch (486 bytes ) - added by James Henstridge 14 years ago.
django-test-client-cookie-fix.patch

Download all attachments as: .zip

Change History (3)

by James Henstridge, 14 years ago

django-test-client-cookie-fix.patch

comment:1 by Russell Keith-Magee, 14 years ago

Resolution: fixed
Status: newclosed

(In [12343]) Fixed #12720 -- Corrected handling of cookies in the TestClient. Thanks to James Henstridge for the report and patch.

comment:2 by Russell Keith-Magee, 14 years ago

(In [12344]) [1.1.X] Fixed #12720 -- Corrected handling of cookies in the TestClient. Thanks to James Henstridge for the report and patch.

Backport of r12343 from trunk.

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