Skip to contentSkip to conversation

testimage: fix unclosed testdata file

PATCH New Ross Burton 1 participant 1 message Oct 15, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 testimage: fix unclosed testdata file

---
 meta/classes/testimage.bbclass | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
meta/classes/testimage.bbclass +4 -3
index a76e773853..4db05a4af4 100644
@@ -235,9 +235,10 @@ def testimage_main(d):
 
     tdname = "%s.testdata.json" % image_name
     try:
-        td = json.load(open(tdname, "r"))
-    except (FileNotFoundError) as err:
-         bb.fatal('File %s Not Found. Have you built the image with INHERIT+="testimage" in the conf/local.conf?' % tdname)
+        with open(tdname, "r") as f:
+            td = json.load(f)
+    except FileNotFoundError as err:
+        bb.fatal('File %s not found (%s).\nHave you built the image with INHERIT += "testimage" in the conf/local.conf?' % (tdname, err))
 
     # Some variables need to be updates (mostly paths) with the
     # ones of the current environment because some tests require them.
Signature · 1 line
2.25.1