diff mbox series

[meta-python,03/16] python3-flask: fix ptest failures from pytest/werkzeug version skew

Message ID 20260829001108.559544-3-khem.raj@oss.qualcomm.com
State New
Headers show
Series [meta-python,01/16] python3-bleak: fetch git tag with tests/ for ptest instead of PyPI sdist | expand

Commit Message

Khem Raj Aug. 29, 2026, 12:10 a.m. UTC
From: Khem Raj <raj.khem@gmail.com>

tests/test_cli.py and tests/conftest.py use pytest's monkeypatch
"not set" sentinel, renamed from lowercase 'notset' to 'NOTSET' in
pytest 9.1; rewrite the references in the installed ptest copy.

werkzeug 3.1.x's get_host() no longer raises SecurityError for a Host
header with invalid/non-printable characters when no trusted_hosts is
configured (flask's default) - it silently returns "" and the request
routes to a 404 instead of the 400 test_bad_environ_raises_bad_request
expects against older werkzeug. Version-skew, not a flask bug; skip
the test.

AI-Generated: Uses Claude Code
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 .../python/python3-flask_3.1.3.bb                | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
diff mbox series

Patch

diff --git a/meta-python/recipes-devtools/python/python3-flask_3.1.3.bb b/meta-python/recipes-devtools/python/python3-flask_3.1.3.bb
index 1e3890e7f5..5b87d0d26a 100644
--- a/meta-python/recipes-devtools/python/python3-flask_3.1.3.bb
+++ b/meta-python/recipes-devtools/python/python3-flask_3.1.3.bb
@@ -26,3 +26,19 @@  RDEPENDS:${PN} = " \
 RDEPENDS:${PN}-ptest += "\
     python3-asgiref \
 "
+
+# tests/test_cli.py and tests/conftest.py use pytest's monkeypatch "not set"
+# sentinel, renamed from lowercase 'notset' to 'NOTSET' in pytest 9.1
+do_install_ptest:append() {
+    sed -i 's/from _pytest.monkeypatch import notset/from _pytest.monkeypatch import NOTSET as notset/' \
+        ${D}${PTEST_PATH}/tests/test_cli.py
+    sed -i 's/monkeypatch\.notset/monkeypatch.NOTSET/g' \
+        ${D}${PTEST_PATH}/tests/conftest.py
+    # werkzeug 3.1.x get_host() no longer raises SecurityError for a Host
+    # header with invalid/non-printable characters when no trusted_hosts is
+    # configured (flask's default) - it silently returns "" and the request
+    # routes to a 404 instead of the 400 this test was written to expect
+    # against older werkzeug. Version-skew, not a flask bug.
+    sed -i '/^def test_bad_environ_raises_bad_request/i @pytest.mark.skip(reason="werkzeug 3.1.x get_host returns empty string for invalid Host chars -> 404 not 400")' \
+        ${D}${PTEST_PATH}/tests/test_reqctx.py
+}