diff mbox series

[v2] python3-six: fix test_lazy failure in ptest

Message ID 20260611065042.2223999-1-Shilong.Jiao@windriver.com
State Changes Requested
Headers show
Series [v2] python3-six: fix test_lazy failure in ptest | expand

Commit Message

Jiao, Shilong June 11, 2026, 6:50 a.m. UTC
From: Shilong Jiao <Shilong.Jiao@windriver.com>

The test_lazy function requires html.parser to not be in sys.modules,
but if test_move_items runs first (which happens in pytest's execution
order), it imports the module causing test_lazy to fail.

Add fix-test-lazy-order.patch to clean up module state before testing
to avoid test order dependency.

Signed-off-by: Shilong Jiao <Shilong.Jiao@windriver.com>
---
 .../python3-six/fix-test-lazy-order.patch     | 23 +++++++++++++++++++
 .../python/python3-six_1.17.0.bb              |  5 +++-
 2 files changed, 27 insertions(+), 1 deletion(-)
 create mode 100644 meta/recipes-devtools/python/python3-six/fix-test-lazy-order.patch

Comments

Alexander Kanavin June 11, 2026, 8:38 a.m. UTC | #1
On Thu, 11 Jun 2026 at 08:50, Jiao, Shilong via lists.openembedded.org
<Shilong.Jiao=eng.windriver.com@lists.openembedded.org> wrote:
> +Ensure test_lazy runs with clean module state
> +
> +The test_lazy function requires html.parser to not be in sys.modules,
> +but if test_move_items runs first, it imports the module causing
> +test_lazy to fail. Clean up the module state before testing.
> +
> +Upstream-Status: Pending

Please submit upstream first.

Alex
diff mbox series

Patch

diff --git a/meta/recipes-devtools/python/python3-six/fix-test-lazy-order.patch b/meta/recipes-devtools/python/python3-six/fix-test-lazy-order.patch
new file mode 100644
index 0000000000..9c22872e1f
--- /dev/null
+++ b/meta/recipes-devtools/python/python3-six/fix-test-lazy-order.patch
@@ -0,0 +1,23 @@ 
+Ensure test_lazy runs with clean module state
+
+The test_lazy function requires html.parser to not be in sys.modules,
+but if test_move_items runs first, it imports the module causing 
+test_lazy to fail. Clean up the module state before testing.
+
+Upstream-Status: Pending
+Signed-off-by: Shilong Jiao <Shilong.Jiao@windriver.com>
+
+--- a/test_six.py
++++ b/test_six.py
+@@ -89,6 +89,9 @@ def test_maxsize():
+ 
+ def test_lazy():
+     if six.PY3:
+         html_name = "html.parser"
+     else:
+         html_name = "HTMLParser"
++    # Ensure clean state for lazy import test
++    sys.modules.pop(html_name, None)
++    six._MovedItems.__dict__.pop("html_parser", None)
+     assert html_name not in sys.modules
+     mod = six.moves.html_parser
diff --git a/meta/recipes-devtools/python/python3-six_1.17.0.bb b/meta/recipes-devtools/python/python3-six_1.17.0.bb
index 213b3dc593..2a12831bea 100644
--- a/meta/recipes-devtools/python/python3-six_1.17.0.bb
+++ b/meta/recipes-devtools/python/python3-six_1.17.0.bb
@@ -3,7 +3,10 @@  require python-six.inc
 
 SRC_URI[sha256sum] = "ff70335d468e7eb6ec65b95b99d3a2836546063f63acc5171de367e834932a81"
 
-SRC_URI += "file://run-ptest"
+SRC_URI += " \
+    file://run-ptest \
+    file://fix-test-lazy-order.patch \
+"
 
 RDEPENDS:${PN}-ptest += " \
     bash \