mirror of
https://github.com/django/django.git
synced 2025-09-09 20:16:32 +00:00
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:
parent
00551c3eff
commit
17e661641d
11 changed files with 105 additions and 12 deletions
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue