]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
oeqa: open JSON to parse in a context manager
authorRoss Burton <ross.burton@arm.com>
Thu, 11 Dec 2025 17:59:06 +0000 (17:59 +0000)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Mon, 15 Dec 2025 18:00:31 +0000 (18:00 +0000)
Use context managers to open the .json files we're about to parse, so
that python doesn't warn about unclosed files.

Signed-off-by: Ross Burton <ross.burton@arm.com>
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/classes-recipe/testexport.bbclass
meta/lib/oeqa/sdk/testmetaidesupport.py
meta/lib/oeqa/sdk/testsdk.py
meta/lib/oeqa/sdkext/testsdk.py

index 344ae489b5a0f0ce899cf2773d6111431025e1e6..12b7e1711290aa1f347b9f115de51b5f32c44dec 100644 (file)
@@ -52,7 +52,8 @@ def testexport_main(d):
                              d.getVar('IMAGE_LINK_NAME') or d.getVar('IMAGE_NAME')))
 
     tdname = "%s.testdata.json" % image_name
-    td = json.load(open(tdname, "r"))
+    with open(tdname, "r") as f:
+        td = json.load(f)
 
     logger = logging.getLogger("BitBake")
 
index 00ef30e82e96565fa1f4f0c278cd4a6354c6a3d2..1110c40b9bfd719eeea9b7141454fc64f43f3196 100644 (file)
@@ -21,7 +21,8 @@ class TestSDK(object):
 
         sdk_envs = OESDKTestContextExecutor._get_sdk_environs(d.getVar("DEPLOY_DIR_IMAGE"))
         tdname = d.expand("${DEPLOY_DIR_IMAGE}/${PN}.testdata.json")
-        test_data = json.load(open(tdname, "r"))
+        with open(tdname, "r") as f:
+            test_data = json.load(f)
 
         host_pkg_manifest = {"cmake-native":"", "gcc-cross":"", "gettext-native":"", "meson-native":"", "perl-native":"", "python3-core-native":"", }
         target_pkg_manifest = {"gtk+3":""}
index cffcf9f49a9ccc4963483ce7995f81aceebb3201..98ef9c71cd61e13fc1d23abbb6c66067cc1639c6 100644 (file)
@@ -103,7 +103,8 @@ class TestSDK(TestSDKBase):
             bb.fatal("The toolchain %s is not built. Build it before running the tests: 'bitbake <image> -c populate_sdk' ." % tcname)
 
         tdname = d.expand("${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.testdata.json")
-        test_data = json.load(open(tdname, "r"))
+        with open(tdname, "r") as f:
+            test_data = json.load(f)
 
         target_pkg_manifest = self.context_executor_class._load_manifest(
             d.expand("${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.target.manifest"))
index 6dc23065a4a098c42dda91c262bd96e689e3648e..4d626f3e0c23c0777b78aa7e5cc0e2c6e63ae432 100644 (file)
@@ -35,7 +35,8 @@ class TestSDKExt(TestSDKBase):
                     " tests: 'bitbake <image> -c populate_sdk_ext' ." % tcname)
 
         tdname = d.expand("${SDK_DEPLOY}/${TOOLCHAINEXT_OUTPUTNAME}.testdata.json")
-        test_data = json.load(open(tdname, "r"))
+        with open(tdname, "r") as f:
+            test_data = json.load(f)
 
         target_pkg_manifest = OESDKExtTestContextExecutor._load_manifest(
             d.expand("${SDK_DEPLOY}/${TOOLCHAINEXT_OUTPUTNAME}.target.manifest"))