[Django] #26666: assertRedirects gives unhelpful error message expected URL is external

13 views
Skip to first unread message

Django

unread,
May 25, 2016, 4:14:06 PM5/25/16
to django-...@googlegroups.com
#26666: assertRedirects gives unhelpful error message expected URL is external
-----------------------------------+--------------------
Reporter: inglesp | Owner: nobody
Type: Bug | Status: new
Component: Testing framework | Version: 1.9
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+--------------------
`assertRedirects` uses the test client and so cannot fetch external URLs.
When the expected URL is set to an external URL, `assertRedirects` fails
with something like:

{{{
AssertionError: 404 != 200 : Couldn't retrieve redirection page '/some-
path/': response code was 404 (expected 200)
}}}

It would be better if `assertRedirects` could detect that it was being
used incorrectly, and gave a more helpful error message.

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

Django

unread,
May 26, 2016, 10:40:10 AM5/26/16
to django-...@googlegroups.com
#26666: assertRedirects gives unhelpful error message expected URL is external
--------------------------------------+------------------------------------
Reporter: inglesp | Owner: nobody
Type: Cleanup/optimization | Status: new

Component: Testing framework | Version: 1.9
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by timgraham):

* needs_better_patch: => 0
* stage: Unreviewed => Accepted
* type: Bug => Cleanup/optimization
* needs_tests: => 0
* needs_docs: => 0


Comment:

The message could suggest using the `fetch_redirect_response=False`
argument.

--
Ticket URL: <https://code.djangoproject.com/ticket/26666#comment:1>

Django

unread,
Jun 2, 2016, 2:00:23 PM6/2/16
to django-...@googlegroups.com
#26666: assertRedirects gives unhelpful error message expected URL is external
-------------------------------------+-------------------------------------
Reporter: inglesp | Owner:
Type: | tobiasmcnulty
Cleanup/optimization | Status: assigned

Component: Testing framework | Version: 1.9
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by tobiasmcnulty):

* status: new => assigned
* owner: nobody => tobiasmcnulty


--
Ticket URL: <https://code.djangoproject.com/ticket/26666#comment:2>

Django

unread,
Jun 2, 2016, 5:40:01 PM6/2/16
to django-...@googlegroups.com
#26666: assertRedirects gives unhelpful error message expected URL is external
-------------------------------------+-------------------------------------
Reporter: inglesp | Owner:
Type: | tobiasmcnulty
Cleanup/optimization | Status: assigned
Component: Testing framework | Version: 1.9
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by tobiasmcnulty):

* has_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/26666#comment:3>

Django

unread,
Jun 2, 2016, 5:45:49 PM6/2/16
to django-...@googlegroups.com
#26666: assertRedirects gives unhelpful error message expected URL is external
-------------------------------------+-------------------------------------
Reporter: inglesp | Owner:
Type: | tobiasmcnulty
Cleanup/optimization | Status: closed

Component: Testing framework | Version: 1.9
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Markus Holtermann <info@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"c7b1b81352533be9b7f4637c12219f59c0964a82" c7b1b81]:
{{{
#!CommitTicketReference repository=""
revision="c7b1b81352533be9b7f4637c12219f59c0964a82"
Fixed #26666 -- Added more useful error message to assertRedirects
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/26666#comment:4>

Django

unread,
Jun 2, 2016, 7:21:34 PM6/2/16
to django-...@googlegroups.com
#26666: assertRedirects gives unhelpful error message expected URL is external
-------------------------------------+-------------------------------------
Reporter: inglesp | Owner:
Type: | tobiasmcnulty
Cleanup/optimization | Status: new
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timgraham):

* status: closed => new
* has_patch: 1 => 0
* version: 1.9 => master
* resolution: fixed =>


Comment:

Tobias is working on fixing the test failures that the patched introduced.

--
Ticket URL: <https://code.djangoproject.com/ticket/26666#comment:5>

Django

unread,
Jun 3, 2016, 12:47:41 AM6/3/16
to django-...@googlegroups.com
#26666: assertRedirects gives unhelpful error message expected URL is external
-------------------------------------+-------------------------------------
Reporter: inglesp | Owner:
Type: | tobiasmcnulty
Cleanup/optimization | Status: new
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Markus Holtermann <info@…>):

In [changeset:"78a0ca67f6dfb6c74dcabe36aa460c4eb5cfe7ae" 78a0ca6]:
{{{
#!CommitTicketReference repository=""
revision="78a0ca67f6dfb6c74dcabe36aa460c4eb5cfe7ae"
Refs #26666 -- Fixed test failures caused by assertRedirects changes
(#6701)
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/26666#comment:6>

Django

unread,
Jun 3, 2016, 6:25:29 PM6/3/16
to django-...@googlegroups.com
#26666: assertRedirects gives unhelpful error message expected URL is external
-------------------------------------+-------------------------------------
Reporter: inglesp | Owner:
Type: | tobiasmcnulty
Cleanup/optimization | Status: new
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by tobiasmcnulty):

* The original fix to this ticket
(https://github.com/django/django/pull/6696) broke unit testing of custom
hostnames in non-core Django projects when the hostname was passed as part
of the path to client.get()
* A new proposed change (https://github.com/django/django/pull/6713)
leverages ALLOWED_HOSTS to facilitate support for custom domain testing in
3rd party packages while increasing the rigor which with we validate
ALLOWED_HOSTS (now also in tests)

--
Ticket URL: <https://code.djangoproject.com/ticket/26666#comment:7>

Django

unread,
Jun 5, 2016, 7:20:21 PM6/5/16
to django-...@googlegroups.com
#26666: assertRedirects gives unhelpful error message expected URL is external
-------------------------------------+-------------------------------------
Reporter: inglesp | Owner:
Type: | tobiasmcnulty
Cleanup/optimization | Status: new
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by charettes):

* has_patch: 0 => 1


Comment:

The code part LGTM but the doc could benefit from a second look of a
native speaker.

--
Ticket URL: <https://code.djangoproject.com/ticket/26666#comment:8>

Django

unread,
Jun 8, 2016, 4:37:37 PM6/8/16
to django-...@googlegroups.com
#26666: assertRedirects gives unhelpful error message expected URL is external
-------------------------------------+-------------------------------------
Reporter: inglesp | Owner:
Type: | tobiasmcnulty
Cleanup/optimization | Status: new
Component: Testing framework | Version: master
Severity: Normal | 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 phildini):

As a native speaker I took a look over the docs, and they make a lot of
sense minus one potentially confusing bit. I left a comment on the PR.

--
Ticket URL: <https://code.djangoproject.com/ticket/26666#comment:9>

Django

unread,
Jun 20, 2016, 11:08:50 AM6/20/16
to django-...@googlegroups.com
#26666: assertRedirects gives unhelpful error message expected URL is external
-------------------------------------+-------------------------------------
Reporter: inglesp | Owner:
Type: | tobiasmcnulty
Cleanup/optimization | Status: new
Component: Testing framework | Version: master
Severity: Normal | 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 Tim Graham <timograham@…>):

In [changeset:"17e661641ddaf8266e7430d83cfb2039abc55df7" 17e66164]:
{{{
#!CommitTicketReference repository=""
revision="17e661641ddaf8266e7430d83cfb2039abc55df7"
Refs #26666 -- Added ALLOWED_HOSTS validation when running tests.

Also used ALLOWED_HOSTS to check for external hosts in assertRedirects().
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/26666#comment:10>

Django

unread,
Jun 20, 2016, 11:19:33 AM6/20/16
to django-...@googlegroups.com
#26666: assertRedirects gives unhelpful error message expected URL is external
-------------------------------------+-------------------------------------
Reporter: inglesp | Owner:
Type: | tobiasmcnulty
Cleanup/optimization | Status: closed

Component: Testing framework | Version: master
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timgraham):

* status: new => closed
* resolution: => fixed


--
Ticket URL: <https://code.djangoproject.com/ticket/26666#comment:11>

Reply all
Reply to author
Forward
0 new messages