#26428: Add support for relative path redirects to the test Client
-----------------------------------+------------------------------------
     Reporter:  master             |                    Owner:  nobody
         Type:  New feature        |                   Status:  new
    Component:  Testing framework  |                  Version:  1.9
     Severity:  Release blocker    |               Resolution:
     Keywords:                     |             Triage Stage:  Accepted
    Has patch:  1                  |      Needs documentation:  0
  Needs tests:  0                  |  Patch needs improvement:  0
Easy pickings:  0                  |                    UI/UX:  0
-----------------------------------+------------------------------------

Comment (by master):

 Replying to [comment:2 timgraham]

 The patch does fix my issue but a simple concatenation doesn't cover all
 cases.
 Suppose your test scenario as: {{{url(r'^accounts/optional_extra$',
 RedirectView.as_view(url='login/')),}}}
 with: {{{response = self.client.get('/accounts/optional_extra')}}}

 I think a more appropriate code is:
 {{{
             # Prepend the request path to handle relative-path redirects.
             if not path.startswith('/'):
                 url = urljoin(response.request['PATH_INFO'], url)
                 path = urljoin(response.request['PATH_INFO'], path)
 }}}

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

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.50bc5e0bb11417e4f309edb49c642ec4%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to