summaryrefslogtreecommitdiffstats
path: root/meta-python/recipes-devtools/python/python3-betamax/fix-failing-ptest.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta-python/recipes-devtools/python/python3-betamax/fix-failing-ptest.patch')
-rw-r--r--meta-python/recipes-devtools/python/python3-betamax/fix-failing-ptest.patch44
1 files changed, 44 insertions, 0 deletions
diff --git a/meta-python/recipes-devtools/python/python3-betamax/fix-failing-ptest.patch b/meta-python/recipes-devtools/python/python3-betamax/fix-failing-ptest.patch
new file mode 100644
index 0000000000..5671033526
--- /dev/null
+++ b/meta-python/recipes-devtools/python/python3-betamax/fix-failing-ptest.patch
@@ -0,0 +1,44 @@
1From 0f5d51b1c7e3b9eb5c083621a00811a872323046 Mon Sep 17 00:00:00 2001
2From: Jaremy Hatler <hatler.jaremy@gmail.com>
3Date: Fri, 22 Dec 2023 22:53:53 -0500
4Subject: [PATCH] fix: clear X-Amzn-Trace-Id in httbin.org responses (#2)
5
6The httbin.org service returns a X-Amzn-Trace-Id header in its
7responses, which is different for each request. This causes the
8tests to fail. This clears the header before comparing responses.
9
10Refs: #184, #190
11Signed-off-by: Jaremy Hatler <hatler.jaremy@gmail.com>
12
13Upstream-Status: Backport [https://github.com/jhatler/betamax/commit/0f5d51b1c7e3b9eb5c083621a00811a872323046]
14---
15 tests/integration/test_record_modes.py | 11 ++++++++++-
16 1 file changed, 10 insertions(+), 1 deletion(-)
17
18diff --git a/tests/integration/test_record_modes.py b/tests/integration/test_record_modes.py
19index 58c8846..988b851 100644
20--- a/tests/integration/test_record_modes.py
21+++ b/tests/integration/test_record_modes.py
22@@ -1,3 +1,5 @@
23+import re
24+
25 from betamax import Betamax, BetamaxError
26
27 from tests.integration.helper import IntegrationHelper
28@@ -39,8 +41,15 @@ def test_replays_response_from_cassette(self):
29 # this test to succeed.
30 # NOTE(hroncok): httpbin.org added X-Processed-Time header that
31 # can possibly differ (and often does)
32+ r0_content = r0.content.decode(encoding='utf-8', errors='strict')
33+ r1_content = r1.content.decode(encoding='utf-8', errors='strict')
34+ r0_content = re.sub('"X-Amzn-Trace-Id": "[^"]+"', '"X-Amzn-Trace-Id": ""', r0_content)
35+ r1_content = re.sub('"X-Amzn-Trace-Id": "[^"]+"', '"X-Amzn-Trace-Id": ""', r1_content)
36+ # NOTE(jhatler): httpbin.org added "X-Amzn-Trace-Id" to their
37+ # response, which is a unique ID that will differ between requests.
38+ # We remove it from the response body before comparing.
39 assert r0_headers == r1_headers
40- assert r0.content == r1.content
41+ assert r0_content == r1_content
42
43
44 class TestRecordNone(IntegrationHelper):