From b476f98381af7e7b369e788fffee817d4e4ebb45 Mon Sep 17 00:00:00 2001 From: Gyorgy Sarvari Date: Sun, 19 Oct 2025 17:59:26 +0200 Subject: python3-betamax: fix ptests 1. Some tests require internet access. Set a DNS for that, if it is not available at the start of the test. 2. Added a backported patch that fixes some failing tests, due to a variable header value contained in a response. (fix-failing-ptest.patch) 3. Added a backported patch that avoids calling pytest fixtures directly. If not applied, tests calling them are marked as failing by pytest. (fix-direct-calls-to-test-fixtures.patch) Signed-off-by: Gyorgy Sarvari --- .../python/python3-betamax/fix-failing-ptest.patch | 44 ++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 meta-python/recipes-devtools/python/python3-betamax/fix-failing-ptest.patch (limited to 'meta-python/recipes-devtools/python/python3-betamax/fix-failing-ptest.patch') 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 @@ +From 0f5d51b1c7e3b9eb5c083621a00811a872323046 Mon Sep 17 00:00:00 2001 +From: Jaremy Hatler +Date: Fri, 22 Dec 2023 22:53:53 -0500 +Subject: [PATCH] fix: clear X-Amzn-Trace-Id in httbin.org responses (#2) + +The httbin.org service returns a X-Amzn-Trace-Id header in its +responses, which is different for each request. This causes the +tests to fail. This clears the header before comparing responses. + +Refs: #184, #190 +Signed-off-by: Jaremy Hatler + +Upstream-Status: Backport [https://github.com/jhatler/betamax/commit/0f5d51b1c7e3b9eb5c083621a00811a872323046] +--- + tests/integration/test_record_modes.py | 11 ++++++++++- + 1 file changed, 10 insertions(+), 1 deletion(-) + +diff --git a/tests/integration/test_record_modes.py b/tests/integration/test_record_modes.py +index 58c8846..988b851 100644 +--- a/tests/integration/test_record_modes.py ++++ b/tests/integration/test_record_modes.py +@@ -1,3 +1,5 @@ ++import re ++ + from betamax import Betamax, BetamaxError + + from tests.integration.helper import IntegrationHelper +@@ -39,8 +41,15 @@ def test_replays_response_from_cassette(self): + # this test to succeed. + # NOTE(hroncok): httpbin.org added X-Processed-Time header that + # can possibly differ (and often does) ++ r0_content = r0.content.decode(encoding='utf-8', errors='strict') ++ r1_content = r1.content.decode(encoding='utf-8', errors='strict') ++ r0_content = re.sub('"X-Amzn-Trace-Id": "[^"]+"', '"X-Amzn-Trace-Id": ""', r0_content) ++ r1_content = re.sub('"X-Amzn-Trace-Id": "[^"]+"', '"X-Amzn-Trace-Id": ""', r1_content) ++ # NOTE(jhatler): httpbin.org added "X-Amzn-Trace-Id" to their ++ # response, which is a unique ID that will differ between requests. ++ # We remove it from the response body before comparing. + assert r0_headers == r1_headers +- assert r0.content == r1.content ++ assert r0_content == r1_content + + + class TestRecordNone(IntegrationHelper): -- cgit v1.2.3-54-g00ecf