Merge "Fix unit tests broken by requests-mock >= 1.12.0"

This commit is contained in:
Zuul 2024-04-30 15:05:36 +00:00 committed by Gerrit Code Review
commit bfd650fe32
1 changed files with 7 additions and 1 deletions

View File

@ -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,