Fix unit tests broken by requests-mock >= 1.12.0
requests-mock removed the old compatibility code in 1.12.0[1] and now usage of a bare dict for response header causes AttributeError. [1] https://github.com/jamielennox/requests-mock/commit/e3bd0d1a92e40fa9cb1d587c59157020a45de620 Closes-Bug: #2064011 Change-Id: Iee86fa3eae86102112987b8648ada73d37ac58e8
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
# under the License.
|
||||
|
||||
import copy
|
||||
from email.message import EmailMessage
|
||||
import io
|
||||
import json
|
||||
import testtools
|
||||
@@ -112,7 +113,12 @@ class FakeResponse(object):
|
||||
self.body = body
|
||||
self.reason = reason
|
||||
self.version = version
|
||||
self.headers = headers
|
||||
# NOTE(tkajinam): Make the FakeResponse class compatible with
|
||||
# http.client.HTTPResponse
|
||||
# https://docs.python.org/3/library/http.client.html
|
||||
self.headers = EmailMessage()
|
||||
for header_key in headers:
|
||||
self.headers[header_key] = headers[header_key]
|
||||
self.headers['x-openstack-request-id'] = 'req-1234'
|
||||
self.status_code = status_code
|
||||
self.raw = RawRequest(headers, body=body, reason=reason,
|
||||
|
||||
Reference in New Issue
Block a user