Skip to contentSkip to conversation

python3-betamax: fix ptests

PATCH New Gyorgy Sarvari 1 participant 1 message Oct 19, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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)

---
 .../fix-direct-calls-to-test-fixtures.patch   | 41 +++++++++++++++++
 .../python3-betamax/fix-failing-ptest.patch   | 44 +++++++++++++++++++
 .../python/python3-betamax/run-ptest          |  6 +++
 .../python/python3-betamax_0.8.1.bb           |  2 +
 4 files changed, 93 insertions(+)
 create mode 100644 meta-python/recipes-devtools/python/python3-betamax/fix-direct-calls-to-test-fixtures.patch
 create mode 100644 meta-python/recipes-devtools/python/python3-betamax/fix-failing-ptest.patch
meta-python/recipes-devtools/python/python3-betamax/fix-direct-calls-to-test-fixtures.patch new file +41 -0
new file mode 100644
index 0000000000..284506867a
@@ -0,0 +1,41 @@
+From 165cc321f2b9839418269e9493b03eb2e43f7ddf Mon Sep 17 00:00:00 2001
+From: Jiri Kuncar <[email protected]>
+Date: Mon, 9 Sep 2019 12:23:18 +0200
+Subject: [PATCH] tests: fix direct calls to PyTest fixtures
+
+https://docs.pytest.org/en/latest/deprecations.html#calling-fixtures-directly
+
+Upstream-Status: Backport [https://github.com/betamaxpy/betamax/commit/165cc321f2b9839418269e9493b03eb2e43f7ddf]
+Signed-off-by: Gyorgy Sarvari <[email protected]>
+---
+ tests/unit/test_fixtures.py | 8 ++++----
+ 1 file changed, 4 insertions(+), 4 deletions(-)
+
+diff --git a/tests/unit/test_fixtures.py b/tests/unit/test_fixtures.py
+index 387d9ce..41f33eb 100644
+--- a/tests/unit/test_fixtures.py
++++ b/tests/unit/test_fixtures.py
+@@ -27,9 +27,9 @@ def test_adds_stop_as_a_finalizer(self):
+         # Mock a pytest request object
+         request = mock.MagicMock()
+         request.cls = request.module = None
+-        request.function.__name__ = 'test'
++        request.node.name = request.function.__name__ = 'test'
+ 
+-        pytest_fixture.betamax_recorder(request)
++        pytest_fixture._betamax_recorder(request)
+         assert request.addfinalizer.called is True
+         request.addfinalizer.assert_called_once_with(self.mocked_betamax.stop)
+ 
+@@ -37,9 +37,9 @@ def test_auto_starts_the_recorder(self):
+         # Mock a pytest request object
+         request = mock.MagicMock()
+         request.cls = request.module = None
+-        request.function.__name__ = 'test'
++        request.node.name = request.function.__name__ = 'test'
+ 
+-        pytest_fixture.betamax_recorder(request)
++        pytest_fixture._betamax_recorder(request)
+         self.mocked_betamax.start.assert_called_once_with()
+ 
+ 
meta-python/recipes-devtools/python/python3-betamax/fix-failing-ptest.patch new file +44 -0

44 lines not on this page · raw message

meta-python/recipes-devtools/python/python3-betamax/run-ptest +6 -0
index b63c4de0d9..7553a6d4bc 100644
@@ -1,3 +1,9 @@
 #!/bin/sh
 
+if ! nslookup httpbin.org >/dev/null 2>&1 ; then
+    trap 'mv /etc/resolv.conf.bak /etc/resolv.conf' INT EXIT
+    mv /etc/resolv.conf /etc/resolv.conf.bak
+    echo "nameserver 8.8.8.8" > /etc/resolv.conf
+fi
+
 pytest -o log_cli=true -o log_cli_level=INFO | sed -e 's/\[...%\]//g'| sed -e 's/PASSED/PASS/g'| sed -e 's/FAILED/FAIL/g'|sed -e 's/SKIPPED/SKIP/g'| awk '{if ($NF=="PASS" || $NF=="FAIL" || $NF=="SKIP" || $NF=="XFAIL" || $NF=="XPASS"){printf "%s: %s\n", $NF, $0}else{print}}'| awk '{if ($NF=="PASS" || $NF=="FAIL" || $NF=="SKIP" || $NF=="XFAIL" || $NF=="XPASS") {$NF="";print $0}else{print}}'
meta-python/recipes-devtools/python/python3-betamax_0.8.1.bb +2 -0
index 2caeb5afa2..2d5b00e595 100644
@@ -5,6 +5,8 @@ LIC_FILES_CHKSUM = "file://LICENSE;md5=61c15f0c146c5fb1a8ce8ba2f310d73c"
 
 SRC_URI += " \
         file://run-ptest \
+        file://fix-failing-ptest.patch \
+        file://fix-direct-calls-to-test-fixtures.patch \
 "
 
 SRC_URI[md5sum] = "b8182d43a200fc126a3bf7555626f964"