Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#12720 closed (fixed)

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

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


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:

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 jamesh 4 years ago.

Download all attachments as: .zip

Change History (3)

Changed 4 years ago by jamesh


comment:1 Changed 4 years ago by russellm

  • Resolution set to fixed
  • Status changed from new to closed

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

comment:2 Changed 4 years ago by russellm

(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.

Add Comment

Modify Ticket

Change Properties
<Author field>
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.