Lines Matching full:self
18 def __enter__(self): argument
21 def emit(self, record): argument
25 self.handler = handler
28 def __exit__(self, type, value, traceback): argument
30 logger.removeHandler(self.handler)
41 def setUp(self): argument
42 self.d = bb.data.init()
43 self.d["foo"] = "value_of_foo"
44 self.d["bar"] = "value_of_bar"
45 self.d["value_of_foo"] = "value_of_'value_of_foo'"
47 def test_one_var(self): argument
48 val = self.d.expand("${foo}")
49 self.assertEqual(str(val), "value_of_foo")
51 def test_indirect_one_var(self): argument
52 val = self.d.expand("${${foo}}")
53 self.assertEqual(str(val), "value_of_'value_of_foo'")
55 def test_indirect_and_another(self): argument
56 val = self.d.expand("${${foo}} ${bar}")
57 self.assertEqual(str(val), "value_of_'value_of_foo' value_of_bar")
59 def test_python_snippet(self): argument
60 val = self.d.expand("${@5*12}")
61 self.assertEqual(str(val), "60")
63 def test_python_snippet_w_dict(self): argument
64 val = self.d.expand("${@{ 'green': 1, 'blue': 2 }['green']}")
65 self.assertEqual(str(val), "1")
67 def test_python_unexpanded_multi(self): argument
68 self.d.setVar("bar", "${unsetvar}")
69 val = self.d.expand("${@2*2},${foo},${@d.getVar('foo') + ' ${bar}'},${foo}")
70 … self.assertEqual(str(val), "4,value_of_foo,${@d.getVar('foo') + ' ${unsetvar}'},value_of_foo")
72 def test_expand_in_python_snippet(self): argument
73 val = self.d.expand("${@'boo ' + '${foo}'}")
74 self.assertEqual(str(val), "boo value_of_foo")
76 def test_python_snippet_getvar(self): argument
77 val = self.d.expand("${@d.getVar('foo') + ' ${bar}'}")
78 self.assertEqual(str(val), "value_of_foo value_of_bar")
80 def test_python_snippet_function_reference(self): argument
81 self.d.setVar("TESTVAL", "testvalue")
82 self.d.setVar("testfunc", 'd.getVar("TESTVAL")')
85 val = self.d.expand("${@testfunc(d)}")
86 self.assertEqual(str(val), "testvalue")
88 def test_python_snippet_builtin_metadata(self): argument
89 self.d.setVar("eval", "INVALID")
90 self.d.expand("${@eval('3')}")
92 def test_python_unexpanded(self): argument
93 self.d.setVar("bar", "${unsetvar}")
94 val = self.d.expand("${@d.getVar('foo') + ' ${bar}'}")
95 self.assertEqual(str(val), "${@d.getVar('foo') + ' ${unsetvar}'}")
97 def test_python_snippet_syntax_error(self): argument
98 self.d.setVar("FOO", "${@foo = 5}")
99 self.assertRaises(bb.data_smart.ExpansionError, self.d.getVar, "FOO", True)
101 def test_python_snippet_runtime_error(self): argument
102 self.d.setVar("FOO", "${@int('test')}")
103 self.assertRaises(bb.data_smart.ExpansionError, self.d.getVar, "FOO", True)
105 def test_python_snippet_error_path(self): argument
106 self.d.setVar("FOO", "foo value ${BAR}")
107 self.d.setVar("BAR", "bar value ${@int('test')}")
108 self.assertRaises(bb.data_smart.ExpansionError, self.d.getVar, "FOO", True)
110 def test_value_containing_value(self): argument
111 val = self.d.expand("${@d.getVar('foo') + ' ${bar}'}")
112 self.assertEqual(str(val), "value_of_foo value_of_bar")
114 def test_reference_undefined_var(self): argument
115 val = self.d.expand("${undefinedvar} meh")
116 self.assertEqual(str(val), "${undefinedvar} meh")
118 def test_double_reference(self): argument
119 self.d.setVar("BAR", "bar value")
120 self.d.setVar("FOO", "${BAR} foo ${BAR}")
121 val = self.d.getVar("FOO")
122 self.assertEqual(str(val), "bar value foo bar value")
124 def test_direct_recursion(self): argument
125 self.d.setVar("FOO", "${FOO}")
126 self.assertRaises(bb.data_smart.ExpansionError, self.d.getVar, "FOO", True)
128 def test_indirect_recursion(self): argument
129 self.d.setVar("FOO", "${BAR}")
130 self.d.setVar("BAR", "${BAZ}")
131 self.d.setVar("BAZ", "${FOO}")
132 self.assertRaises(bb.data_smart.ExpansionError, self.d.getVar, "FOO", True)
134 def test_recursion_exception(self): argument
135 self.d.setVar("FOO", "${BAR}")
136 self.d.setVar("BAR", "${${@'FOO'}}")
137 self.assertRaises(bb.data_smart.ExpansionError, self.d.getVar, "FOO", True)
139 def test_incomplete_varexp_single_quotes(self): argument
140 self.d.setVar("FOO", "sed -i -e 's:IP{:I${:g' $pc")
141 val = self.d.getVar("FOO")
142 self.assertEqual(str(val), "sed -i -e 's:IP{:I${:g' $pc")
144 def test_nonstring(self): argument
145 self.d.setVar("TEST", 5)
146 val = self.d.getVar("TEST")
147 self.assertEqual(str(val), "5")
149 def test_rename(self): argument
150 self.d.renameVar("foo", "newfoo")
151 self.assertEqual(self.d.getVar("newfoo", False), "value_of_foo")
152 self.assertEqual(self.d.getVar("foo", False), None)
154 def test_deletion(self): argument
155 self.d.delVar("foo")
156 self.assertEqual(self.d.getVar("foo", False), None)
158 def test_keys(self): argument
159 keys = list(self.d.keys())
160 self.assertCountEqual(keys, ['value_of_foo', 'foo', 'bar'])
162 def test_keys_deletion(self): argument
163 newd = bb.data.createCopy(self.d)
166 self.assertCountEqual(keys, ['value_of_foo', 'foo'])
169 def setUp(self): argument
170 self.d = bb.data.init()
171 self.d["foo"] = "foo"
172 self.d["bar"] = "bar"
173 self.d["value_of_foobar"] = "187"
175 def test_refs(self): argument
176 val = self.d.expand("${value_of_${foo}${bar}}")
177 self.assertEqual(str(val), "187")
179 #def test_python_refs(self):
180 # val = self.d.expand("${@${@3}**2 + ${@4}**2}")
181 # self.assertEqual(str(val), "25")
183 def test_ref_in_python_ref(self): argument
184 val = self.d.expand("${@'${foo}' + 'bar'}")
185 self.assertEqual(str(val), "foobar")
187 def test_python_ref_in_ref(self): argument
188 val = self.d.expand("${${@'f'+'o'+'o'}}")
189 self.assertEqual(str(val), "foo")
191 def test_deep_nesting(self): argument
193 val = self.d.expand("${" * depth + "foo" + "}" * depth)
194 self.assertEqual(str(val), "foo")
196 #def test_deep_python_nesting(self):
198 # val = self.d.expand("${@" * depth + "1" + "+1}" * depth)
199 # self.assertEqual(str(val), str(depth + 1))
201 def test_mixed(self): argument
202 val = self.d.expand("${value_of_${@('${foo}'+'bar')[0:3]}${${@'BAR'.lower()}}}")
203 self.assertEqual(str(val), "187")
205 def test_runtime(self): argument
206 val = self.d.expand("${${@'value_of' + '_f'+'o'+'o'+'b'+'a'+'r'}}")
207 self.assertEqual(str(val), "187")
210 def test_memoized(self): argument
213 self.assertTrue(d.getVar("FOO", False) is d.getVar("FOO", False))
215 def test_not_memoized(self): argument
220 self.assertTrue(d1.getVar("FOO", False) is not d2.getVar("FOO", False))
222 def test_changed_after_memoized(self): argument
225 self.assertEqual(str(d.getVar("foo", False)), "value of foo")
227 self.assertEqual(str(d.getVar("foo", False)), "second value of foo")
229 def test_same_value(self): argument
233 self.assertEqual(d.getVar("foo", False),
237 def setUp(self): argument
238 self.d = bb.data.init()
239 self.d.setVar("FOO", "foo")
240 self.d.setVar("VAL", "val")
241 self.d.setVar("BAR", "bar")
243 def test_prepend(self): argument
244 self.d.setVar("TEST", "${VAL}")
245 self.d.prependVar("TEST", "${FOO}:")
246 self.assertEqual(self.d.getVar("TEST"), "foo:val")
248 def test_append(self): argument
249 self.d.setVar("TEST", "${VAL}")
250 self.d.appendVar("TEST", ":${BAR}")
251 self.assertEqual(self.d.getVar("TEST"), "val:bar")
253 def test_multiple_append(self): argument
254 self.d.setVar("TEST", "${VAL}")
255 self.d.prependVar("TEST", "${FOO}:")
256 self.d.appendVar("TEST", ":val2")
257 self.d.appendVar("TEST", ":${BAR}")
258 self.assertEqual(self.d.getVar("TEST"), "foo:val:val2:bar")
261 def setUp(self): argument
262 self.d = bb.data.init()
263 self.d.setVar("FOO", "foo")
264 self.d.setVar("VAL", "val")
265 self.d.setVar("BAR", "bar")
267 def test_prepend(self): argument
268 self.d.setVar("TEST", "${VAL}")
269 self.d.setVar("TEST:prepend", "${FOO}:")
270 self.assertEqual(self.d.getVar("TEST"), "foo:val")
272 def test_append(self): argument
273 self.d.setVar("TEST", "${VAL}")
274 self.d.setVar("TEST:append", ":${BAR}")
275 self.assertEqual(self.d.getVar("TEST"), "val:bar")
277 def test_multiple_append(self): argument
278 self.d.setVar("TEST", "${VAL}")
279 self.d.setVar("TEST:prepend", "${FOO}:")
280 self.d.setVar("TEST:append", ":val2")
281 self.d.setVar("TEST:append", ":${BAR}")
282 self.assertEqual(self.d.getVar("TEST"), "foo:val:val2:bar")
284 def test_append_unset(self): argument
285 self.d.setVar("TEST:prepend", "${FOO}:")
286 self.d.setVar("TEST:append", ":val2")
287 self.d.setVar("TEST:append", ":${BAR}")
288 self.assertEqual(self.d.getVar("TEST"), "foo::val2:bar")
290 def test_remove(self): argument
291 self.d.setVar("TEST", "${VAL} ${BAR}")
292 self.d.setVar("TEST:remove", "val")
293 self.assertEqual(self.d.getVar("TEST"), " bar")
295 def test_remove_cleared(self): argument
296 self.d.setVar("TEST", "${VAL} ${BAR}")
297 self.d.setVar("TEST:remove", "val")
298 self.d.setVar("TEST", "${VAL} ${BAR}")
299 self.assertEqual(self.d.getVar("TEST"), "val bar")
303 def test_remove_inactive_override(self): argument
304 self.d.setVar("TEST", "${VAL} ${BAR} 123")
305 self.d.setVar("TEST:remove:inactiveoverride", "val")
306 self.assertEqual(self.d.getVar("TEST"), "val bar 123")
308 def test_doubleref_remove(self): argument
309 self.d.setVar("TEST", "${VAL} ${BAR}")
310 self.d.setVar("TEST:remove", "val")
311 self.d.setVar("TEST_TEST", "${TEST} ${TEST}")
312 self.assertEqual(self.d.getVar("TEST_TEST"), " bar bar")
314 def test_empty_remove(self): argument
315 self.d.setVar("TEST", "")
316 self.d.setVar("TEST:remove", "val")
317 self.assertEqual(self.d.getVar("TEST"), "")
319 def test_remove_expansion(self): argument
320 self.d.setVar("BAR", "Z")
321 self.d.setVar("TEST", "${BAR}/X Y")
322 self.d.setVar("TEST:remove", "${BAR}/X")
323 self.assertEqual(self.d.getVar("TEST"), " Y")
325 def test_remove_expansion_items(self): argument
326 self.d.setVar("TEST", "A B C D")
327 self.d.setVar("BAR", "B D")
328 self.d.setVar("TEST:remove", "${BAR}")
329 self.assertEqual(self.d.getVar("TEST"), "A C ")
331 def test_remove_preserve_whitespace(self): argument
333 self.d.setVar("TEST", " A B")
334 self.d.setVar("TEST:remove", "C")
335 self.assertEqual(self.d.getVar("TEST"), " A B")
337 def test_remove_preserve_whitespace2(self): argument
339 self.d.setVar("TEST", " A B")
340 self.d.setVar("TEST:remove", "B")
341 self.assertEqual(self.d.getVar("TEST"), " A ")
344 def setUp(self): argument
345 self.d = bb.data.init()
346 self.d.setVar("OVERRIDES", "foo:bar:local")
347 self.d.setVar("TEST", "testvalue")
349 def test_no_override(self): argument
350 self.assertEqual(self.d.getVar("TEST"), "testvalue")
352 def test_one_override(self): argument
353 self.d.setVar("TEST:bar", "testvalue2")
354 self.assertEqual(self.d.getVar("TEST"), "testvalue2")
356 def test_one_override_unset(self): argument
357 self.d.setVar("TEST2:bar", "testvalue2")
359 self.assertEqual(self.d.getVar("TEST2"), "testvalue2")
360 self.assertCountEqual(list(self.d.keys()), ['TEST', 'TEST2', 'OVERRIDES', 'TEST2:bar'])
362 def test_multiple_override(self): argument
363 self.d.setVar("TEST:bar", "testvalue2")
364 self.d.setVar("TEST:local", "testvalue3")
365 self.d.setVar("TEST:foo", "testvalue4")
366 self.assertEqual(self.d.getVar("TEST"), "testvalue3")
367 …self.assertCountEqual(list(self.d.keys()), ['TEST', 'TEST:foo', 'OVERRIDES', 'TEST:bar', 'TEST:loc…
369 def test_multiple_combined_overrides(self): argument
370 self.d.setVar("TEST:local:foo:bar", "testvalue3")
371 self.assertEqual(self.d.getVar("TEST"), "testvalue3")
373 def test_multiple_overrides_unset(self): argument
374 self.d.setVar("TEST2:local:foo:bar", "testvalue3")
375 self.assertEqual(self.d.getVar("TEST2"), "testvalue3")
377 def test_keyexpansion_override(self): argument
378 self.d.setVar("LOCAL", "local")
379 self.d.setVar("TEST:bar", "testvalue2")
380 self.d.setVar("TEST:${LOCAL}", "testvalue3")
381 self.d.setVar("TEST:foo", "testvalue4")
382 bb.data.expandKeys(self.d)
383 self.assertEqual(self.d.getVar("TEST"), "testvalue3")
385 def test_rename_override(self): argument
386 self.d.setVar("ALTERNATIVE:ncurses-tools:class-target", "a")
387 self.d.setVar("OVERRIDES", "class-target")
388 self.d.renameVar("ALTERNATIVE:ncurses-tools", "ALTERNATIVE:lib32-ncurses-tools")
389 self.assertEqual(self.d.getVar("ALTERNATIVE:lib32-ncurses-tools"), "a")
391 def test_underscore_override(self): argument
392 self.d.setVar("TEST:bar", "testvalue2")
393 self.d.setVar("TEST:some_val", "testvalue3")
394 self.d.setVar("TEST:foo", "testvalue4")
395 self.d.setVar("OVERRIDES", "foo:bar:some_val")
396 self.assertEqual(self.d.getVar("TEST"), "testvalue3")
399 def test_underscore_override_2(self): argument
400 self.d.setVar("TARGET_ARCH", "x86_64")
401 self.d.setVar("PN", "test-${TARGET_ARCH}")
402 self.d.setVar("VERSION", "1")
403 self.d.setVar("VERSION:pn-test-${TARGET_ARCH}", "2")
404 self.d.setVar("OVERRIDES", "pn-${PN}")
405 bb.data.expandKeys(self.d)
406 self.assertEqual(self.d.getVar("VERSION"), "2")
408 def test_remove_with_override(self): argument
409 self.d.setVar("TEST:bar", "testvalue2")
410 self.d.setVar("TEST:some_val", "testvalue3 testvalue5")
411 self.d.setVar("TEST:some_val:remove", "testvalue3")
412 self.d.setVar("TEST:foo", "testvalue4")
413 self.d.setVar("OVERRIDES", "foo:bar:some_val")
414 self.assertEqual(self.d.getVar("TEST"), " testvalue5")
416 def test_append_and_override_1(self): argument
417 self.d.setVar("TEST:append", "testvalue2")
418 self.d.setVar("TEST:bar", "testvalue3")
419 self.assertEqual(self.d.getVar("TEST"), "testvalue3testvalue2")
421 def test_append_and_override_2(self): argument
422 self.d.setVar("TEST:append:bar", "testvalue2")
423 self.assertEqual(self.d.getVar("TEST"), "testvaluetestvalue2")
425 def test_append_and_override_3(self): argument
426 self.d.setVar("TEST:bar:append", "testvalue2")
427 self.assertEqual(self.d.getVar("TEST"), "testvalue2")
429 def test_append_and_unused_override(self): argument
431 self.d.setVar("BAR:append:unusedoverride", "testvalue2")
432 self.assertEqual(self.d.getVar("BAR"), None)
435 def setUp(self): argument
436 self.d = bb.data.init()
437 self.d.setVar("FOO", "foo")
438 self.d.setVar("BAR", "foo")
440 def test_keyexpand(self): argument
441 self.d.setVar("VAL_${FOO}", "A")
442 self.d.setVar("VAL_${BAR}", "B")
444 bb.data.expandKeys(self.d)
445 …self.assertTrue(logContains("Variable key VAL_${FOO} (A) replaces original key VAL_foo (B)", logs))
446 self.assertEqual(self.d.getVar("VAL_foo"), "A")
449 def setUp(self): argument
450 self.d = bb.data.init()
451 self.d.setVar("foo", "value of foo")
452 self.d.setVarFlag("foo", "flag1", "value of flag1")
453 self.d.setVarFlag("foo", "flag2", "value of flag2")
455 def test_setflag(self): argument
456 self.assertEqual(self.d.getVarFlag("foo", "flag1", False), "value of flag1")
457 self.assertEqual(self.d.getVarFlag("foo", "flag2", False), "value of flag2")
459 def test_delflag(self): argument
460 self.d.delVarFlag("foo", "flag2")
461 self.assertEqual(self.d.getVarFlag("foo", "flag1", False), "value of flag1")
462 self.assertEqual(self.d.getVarFlag("foo", "flag2", False), None)
466 def setUp(self): argument
467 self.d = bb.data.init()
468 self.d.setVar("SOMEFLAG", "a b c")
470 def test_contains(self): argument
471 self.assertTrue(bb.utils.contains("SOMEFLAG", "a", True, False, self.d))
472 self.assertTrue(bb.utils.contains("SOMEFLAG", "b", True, False, self.d))
473 self.assertTrue(bb.utils.contains("SOMEFLAG", "c", True, False, self.d))
475 self.assertTrue(bb.utils.contains("SOMEFLAG", "a b", True, False, self.d))
476 self.assertTrue(bb.utils.contains("SOMEFLAG", "b c", True, False, self.d))
477 self.assertTrue(bb.utils.contains("SOMEFLAG", "c a", True, False, self.d))
479 self.assertTrue(bb.utils.contains("SOMEFLAG", "a b c", True, False, self.d))
480 self.assertTrue(bb.utils.contains("SOMEFLAG", "c b a", True, False, self.d))
482 self.assertFalse(bb.utils.contains("SOMEFLAG", "x", True, False, self.d))
483 self.assertFalse(bb.utils.contains("SOMEFLAG", "a x", True, False, self.d))
484 self.assertFalse(bb.utils.contains("SOMEFLAG", "x c b", True, False, self.d))
485 self.assertFalse(bb.utils.contains("SOMEFLAG", "x c b a", True, False, self.d))
487 def test_contains_any(self): argument
488 self.assertTrue(bb.utils.contains_any("SOMEFLAG", "a", True, False, self.d))
489 self.assertTrue(bb.utils.contains_any("SOMEFLAG", "b", True, False, self.d))
490 self.assertTrue(bb.utils.contains_any("SOMEFLAG", "c", True, False, self.d))
492 self.assertTrue(bb.utils.contains_any("SOMEFLAG", "a b", True, False, self.d))
493 self.assertTrue(bb.utils.contains_any("SOMEFLAG", "b c", True, False, self.d))
494 self.assertTrue(bb.utils.contains_any("SOMEFLAG", "c a", True, False, self.d))
496 self.assertTrue(bb.utils.contains_any("SOMEFLAG", "a x", True, False, self.d))
497 self.assertTrue(bb.utils.contains_any("SOMEFLAG", "x c", True, False, self.d))
499 self.assertFalse(bb.utils.contains_any("SOMEFLAG", "x", True, False, self.d))
500 self.assertFalse(bb.utils.contains_any("SOMEFLAG", "x y z", True, False, self.d))
504 def test_taskhashes(self): argument
522 self.assertNotEqual(orighash, nexthash)
529 self.assertEqual(orighash, nexthash)
534 self.assertNotEqual(orighash, nexthash)
543 self.assertNotEqual(orighash, nexthash)
549 self.assertEqual(orighash, nexthash)
553 def test_serialize(self): argument
569 self.assertEqual(d, newd)
570 self.assertEqual(newd.getVar('HELLO'), 'world')
571 self.assertEqual(newd.getVarFlag('HELLO', 'other'), 'planet')