mirror of
https://git.yoctoproject.org/poky
synced 2026-05-30 00:20:08 +00:00
bitbake: utils: add environment updating context manager
bb.utils.environment() is a context manager to alter os.environ inside a specific block, restoring it after the block is closed. (Bitbake rev: 9974848f67581ff7d76cef52a94f505af99b4932) Signed-off-by: Ross Burton <ross.burton@arm.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
0975ff9b69
commit
62098f9041
@@ -666,3 +666,21 @@ class GetReferencedVars(unittest.TestCase):
|
||||
|
||||
layers = [{"SRC_URI"}, {"QT_GIT", "QT_MODULE", "QT_MODULE_BRANCH_PARAM", "QT_GIT_PROTOCOL"}, {"QT_GIT_PROJECT", "QT_MODULE_BRANCH", "BPN"}, {"PN", "SPECIAL_PKGSUFFIX"}]
|
||||
self.check_referenced("${SRC_URI}", layers)
|
||||
|
||||
|
||||
class EnvironmentTests(unittest.TestCase):
|
||||
def test_environment(self):
|
||||
os.environ["A"] = "this is A"
|
||||
self.assertIn("A", os.environ)
|
||||
self.assertEqual(os.environ["A"], "this is A")
|
||||
self.assertNotIn("B", os.environ)
|
||||
|
||||
with bb.utils.environment(B="this is B"):
|
||||
self.assertIn("A", os.environ)
|
||||
self.assertEqual(os.environ["A"], "this is A")
|
||||
self.assertIn("B", os.environ)
|
||||
self.assertEqual(os.environ["B"], "this is B")
|
||||
|
||||
self.assertIn("A", os.environ)
|
||||
self.assertEqual(os.environ["A"], "this is A")
|
||||
self.assertNotIn("B", os.environ)
|
||||
|
||||
Reference in New Issue
Block a user