Add patch for compatibility with newer requests-mock
Change-Id: Ie6a888f1fc45b834811714c65fd705bed739a55e
This commit is contained in:
parent
94e635d821
commit
bdc0b11dd1
@ -0,0 +1,45 @@
|
||||
From 300b8c8262d8dcdca7a8d753c3fb8a22cae02d40 Mon Sep 17 00:00:00 2001
|
||||
From: Takashi Kajinami <kajinamit@oss.nttdata.com>
|
||||
Date: Sun, 28 Apr 2024 22:19:24 +0900
|
||||
Subject: [PATCH] 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
|
||||
---
|
||||
glanceclient/tests/utils.py | 8 +++++++-
|
||||
1 file changed, 7 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/glanceclient/tests/utils.py b/glanceclient/tests/utils.py
|
||||
index 730b928..750fb7e 100644
|
||||
--- a/glanceclient/tests/utils.py
|
||||
+++ b/glanceclient/tests/utils.py
|
||||
@@ -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,
|
||||
--
|
||||
2.44.0
|
||||
|
@ -12,6 +12,8 @@ License: {{ license('Apache-2.0') }}
|
||||
Group: Development/Languages/Python
|
||||
URL: https://docs.openstack.org/{{ pypi_name }}
|
||||
Source0: {{ source }}
|
||||
# https://review.opendev.org/c/openstack/python-glanceclient/+/917275
|
||||
Patch1: 0001-Fix-unit-tests-broken-by-requests-mock-1.12.0.patch
|
||||
BuildRequires: openstack-macros
|
||||
BuildRequires: {{ py3('PrettyTable') }}
|
||||
BuildRequires: {{ py3('ddt') }}
|
||||
|
Loading…
x
Reference in New Issue
Block a user