From fc8468024cf47cb7019e0167e7e07f24131c85b1 Mon Sep 17 00:00:00 2001 From: Christopher Larson Date: Thu, 17 Mar 2022 15:33:54 -0700 Subject: bitbake: tests.data: add test for inline python calling a def'd function This is a test for an issue seen long ago, to avoid regressions, where a reference to a def'd function in the metadata would return the string value from the metadata rather than the function in inline python. (Bitbake rev: 9f7cb22febd557817c164e25a93f5660e9c06358) Signed-off-by: Christopher Larson Signed-off-by: Richard Purdie --- bitbake/lib/bb/tests/data.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'bitbake/lib/bb/tests/data.py') diff --git a/bitbake/lib/bb/tests/data.py b/bitbake/lib/bb/tests/data.py index 8c043b709d..251130b857 100644 --- a/bitbake/lib/bb/tests/data.py +++ b/bitbake/lib/bb/tests/data.py @@ -77,6 +77,15 @@ class DataExpansions(unittest.TestCase): val = self.d.expand("${@d.getVar('foo') + ' ${bar}'}") self.assertEqual(str(val), "value_of_foo value_of_bar") + def test_python_snippet_function_reference(self): + self.d.setVar("TESTVAL", "testvalue") + self.d.setVar("testfunc", 'd.getVar("TESTVAL")') + self.d.setVarFlag("testfunc", "func", "1") + context = bb.utils.get_context() + context["testfunc"] = lambda d: d.getVar("TESTVAL") + val = self.d.expand("${@testfunc(d)}") + self.assertEqual(str(val), "testvalue") + def test_python_unexpanded(self): self.d.setVar("bar", "${unsetvar}") val = self.d.expand("${@d.getVar('foo') + ' ${bar}'}") -- cgit v1.2.3-54-g00ecf