Refs #26666 -- Added ALLOWED_HOSTS validation when running tests.

Also used ALLOWED_HOSTS to check for external hosts in assertRedirects().
This commit is contained in:
Tobias McNulty 2016-06-03 15:02:38 -07:00 committed by Tim Graham
parent 00551c3eff
commit 17e661641d
11 changed files with 105 additions and 12 deletions

View file

@ -601,7 +601,13 @@ class ClientTest(TestCase):
a relevant ValueError rather than a non-descript AssertionError.
"""
response = self.client.get('/django_project_redirect/')
with self.assertRaisesMessage(ValueError, 'unable to fetch'):
msg = (
"The test client is unable to fetch remote URLs (got "
"https://www.djangoproject.com/). If the host is served by Django, "
"add 'www.djangoproject.com' to ALLOWED_HOSTS. "
"Otherwise, use assertRedirects(..., fetch_redirect_response=False)."
)
with self.assertRaisesMessage(ValueError, msg):
self.assertRedirects(response, 'https://www.djangoproject.com/')
def test_session_modifying_view(self):