Support Django 3.2 support (1)

Django 3.2 defines the new header API for the response object [1].
This change dropped "_headers" attribute from the response object.
Instead of accesing a private attribute, we need to use the public APIs
for response headers [2].

[1] https://docs.djangoproject.com/en/3.2/releases/3.2/#requests-and-responses
[2] https://docs.djangoproject.com/en/3.2/ref/request-response/#httpresponse-objects

Change-Id: Ia13212fd231215e17f4bba2039e79874b676e634
This commit is contained in:
Akihiro Motoki 2021-02-24 23:45:45 +09:00 committed by Vishal Manchanda
parent 44b7c03fba
commit e77633c56a
1 changed files with 4 additions and 1 deletions

View File

@ -279,7 +279,10 @@ class TestCase(horizon_helpers.TestCase):
Asserts that the given response issued a 302 redirect without
processing the view which is redirected to.
"""
loc = str(response._headers.get('location', None)[1])
if response.has_header('location'):
loc = response['location']
else:
loc = ''
loc = http.urlunquote(loc)
expected_url = http.urlunquote(expected_url)
self.assertEqual(loc, expected_url)