Debian Codegraph @

debian/patches/Fix_bytes-related_test_failures_with_urllib-3.patch

raw
1 From 106cfe5633498d13a518e7d1db74a5efabe509fc Mon Sep 17 00:00:00 2001
2 From: Michał Górny <[email protected]>
3 Date: Tue, 18 Jun 2024 07:13:58 +0200
4 Subject: [PATCH] Fix bytes-related test failures with urllib-3
5
6 Replace `io.StringIO()` with `io.BytesIO()` in mocked response body,
7 to fix some of the test failures when running with urllib3-2.2.1. This
8 change is backwards compatible — all tests still pass with
9 urllib3-1.26.18.
10
11 Partial-Bug: 2069684
12 Change-Id: Ic9036a997d2e1b7c79baf7edca129c165b96aabb
13 ---
14
15 Index: python-glanceclient/glanceclient/tests/unit/test_http.py
16 ===================================================================
17 --- python-glanceclient.orig/glanceclient/tests/unit/test_http.py
18 +++ python-glanceclient/glanceclient/tests/unit/test_http.py
19 @@ -341,9 +341,9 @@ class TestClient(testtools.TestCase):
20 self.assertEqual(data, json.loads(self.mock.last_request.body))
21
22 def test_http_chunked_response(self):
23 - data = "TEST"
24 + data = b"TEST"
25 path = '/v1/images/'
26 - self.mock.get(self.endpoint + path, body=io.StringIO(data),
27 + self.mock.get(self.endpoint + path, body=io.BytesIO(data),
28 headers={"Content-Type": "application/octet-stream"})
29
30 resp, body = self.client.get(path)
31 @@ -457,9 +457,9 @@ class TestClient(testtools.TestCase):
32
33 def test_log_request_id_once(self):
34 logger = self.useFixture(fixtures.FakeLogger(level=logging.DEBUG))
35 - data = "TEST"
36 + data = b"TEST"
37 path = '/v1/images/'
38 - self.mock.get(self.endpoint + path, body=io.StringIO(data),
39 + self.mock.get(self.endpoint + path, body=io.BytesIO(data),
40 headers={"Content-Type": "application/octet-stream",
41 'x-openstack-request-id': "1234"})
42