aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher Larson <kergoth@gmail.com>2022-03-17 15:33:54 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2023-08-04 11:36:44 +0100
commit9f7cb22febd557817c164e25a93f5660e9c06358 (patch)
tree03fbd62efee0d050efa6b170301d92938f8f5efb
parentb7109acb96e416e3c537b6b51f7c1fec2ca89371 (diff)
downloadbitbake-9f7cb22febd557817c164e25a93f5660e9c06358.tar.gz
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. Signed-off-by: Christopher Larson <kergoth@gmail.com>
-rw-r--r--lib/bb/tests/data.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/bb/tests/data.py b/lib/bb/tests/data.py
index 8c043b709..251130b85 100644
--- a/lib/bb/tests/data.py
+++ b/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}'}")