@@ -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")
@@ -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":""}
@@ -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"))
@@ -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"))
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> --- meta/classes-recipe/testexport.bbclass | 3 ++- meta/lib/oeqa/sdk/testmetaidesupport.py | 3 ++- meta/lib/oeqa/sdk/testsdk.py | 3 ++- meta/lib/oeqa/sdkext/testsdk.py | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-)