diff mbox series

[v2,1/2] tests/data: Remove testfunc from the global context after use

Message ID 20261117203716.3276852-1-maxime.roussinbelanger@gmail.com
State New
Headers show
Series [v2,1/2] tests/data: Remove testfunc from the global context after use | expand

Commit Message

Maxime Roussin-Belanger Nov. 17, 2026, 8:37 p.m. UTC
test_python_snippet_function_reference() adds testfunc to the global
context and leaves it there, so every test that runs later in the same
process sees it.

AI-Generated: Uses Claude Code (Claude Opus 5.5)
Signed-off-by: Maxime Roussin-Belanger <maxime.roussinbelanger@gmail.com>
---
 lib/bb/tests/data.py | 1 +
 1 file changed, 1 insertion(+)
diff mbox series

Patch

diff --git a/lib/bb/tests/data.py b/lib/bb/tests/data.py
index 491774747..a2b0f43cb 100644
--- a/lib/bb/tests/data.py
+++ b/lib/bb/tests/data.py
@@ -83,6 +83,7 @@  class DataExpansions(unittest.TestCase):
         self.d.setVar("testfunc", 'd.getVar("TESTVAL")')
         context = bb.utils.get_context()
         context["testfunc"] = lambda d: d.getVar("TESTVAL")
+        self.addCleanup(context.pop, "testfunc")
         val = self.d.expand("${@testfunc(d)}")
         self.assertEqual(str(val), "testvalue")