File: Fix_bytes-related_test_failures_with_urllib-3.patch

package info (click to toggle)
python-glanceclient 1%3A4.8.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,664 kB
  • sloc: python: 16,456; sh: 71; makefile: 29
file content (42 lines) | stat: -rw-r--r-- 1,821 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
From 106cfe5633498d13a518e7d1db74a5efabe509fc Mon Sep 17 00:00:00 2001
From: Michał Górny <mgorny@gentoo.org>
Date: Tue, 18 Jun 2024 07:13:58 +0200
Subject: [PATCH] Fix bytes-related test failures with urllib-3

Replace `io.StringIO()` with `io.BytesIO()` in mocked response body,
to fix some of the test failures when running with urllib3-2.2.1.  This
change is backwards compatible — all tests still pass with
urllib3-1.26.18.

Partial-Bug: 2069684
Change-Id: Ic9036a997d2e1b7c79baf7edca129c165b96aabb
---

Index: python-glanceclient/glanceclient/tests/unit/test_http.py
===================================================================
--- python-glanceclient.orig/glanceclient/tests/unit/test_http.py
+++ python-glanceclient/glanceclient/tests/unit/test_http.py
@@ -341,9 +341,9 @@ class TestClient(testtools.TestCase):
         self.assertEqual(data, json.loads(self.mock.last_request.body))
 
     def test_http_chunked_response(self):
-        data = "TEST"
+        data = b"TEST"
         path = '/v1/images/'
-        self.mock.get(self.endpoint + path, body=io.StringIO(data),
+        self.mock.get(self.endpoint + path, body=io.BytesIO(data),
                       headers={"Content-Type": "application/octet-stream"})
 
         resp, body = self.client.get(path)
@@ -457,9 +457,9 @@ class TestClient(testtools.TestCase):
 
     def test_log_request_id_once(self):
         logger = self.useFixture(fixtures.FakeLogger(level=logging.DEBUG))
-        data = "TEST"
+        data = b"TEST"
         path = '/v1/images/'
-        self.mock.get(self.endpoint + path, body=io.StringIO(data),
+        self.mock.get(self.endpoint + path, body=io.BytesIO(data),
                       headers={"Content-Type": "application/octet-stream",
                                'x-openstack-request-id': "1234"})