Opened 5 years ago

Last modified 3 months ago

#12227 assigned Bug

PREPEND_WWW breaks the test client

Reported by: andybak Owned by: Sharpek
Component: Testing framework Version: 1.1
Severity: Normal Keywords: test client, redirect, prepend_www
Cc: andy@… Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


With PREPEND_WWW set to true the test client will always give a 301 status_code:

    >>> from django.test.client import Client
    >>> c = Client()
    >>> r = c.get('/admin/', follow=True)
    >>> r.status_code
    >>> r.redirect_chain
    [('http://www.testserver/admin/', 301), ('http://www.testserver/admin/', 301)]

Attachments (1)

12227.diff (1.2 KB) - added by mlavin 3 years ago.
Added failing test case.

Download all attachments as: .zip

Change History (7)

comment:1 Changed 5 years ago by stavros

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

+1, this behaviour serves no purpose. It only makes testing difficult and forces me to never use prepend_www and rather do my redirects at the webserver level. Perhaps PREPEND_WWW should be disabled before every test automatically, since it's not what testing is supposed to test for?

comment:2 Changed 4 years ago by ericholscher

  • Triage Stage changed from Unreviewed to Accepted

comment:3 Changed 3 years ago by mattmcc

  • Severity set to Normal
  • Type set to Bug

Changed 3 years ago by mlavin

Added failing test case.

comment:4 Changed 3 years ago by mlavin

  • Easy pickings unset
  • UI/UX unset

Not sure how to fix but I've added a test case which demonstrates the described issue.

comment:5 Changed 3 months ago by Sharpek

  • Owner changed from nobody to Sharpek
  • Status changed from new to assigned

comment:6 Changed 3 months ago by Sharpek

I' going to check&fix this issue.

Add Comment

Modify Ticket

Change Properties
<Author field>
as assigned
The owner will be changed from Sharpek to anonymous. Next status will be 'assigned'
The ticket will be disowned. Next status will be 'new'
as The resolution will be set. Next status will be 'closed'

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

Note: See TracTickets for help on using tickets.