summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2019-10-09 14:20:23 +0400
committerDavid Gibson <david@gibson.dropbear.id.au>2019-10-14 17:09:13 +1100
commit430419c28100960c554cf753a5309231c03ec780 (patch)
treeaa22a0e4c951f16c062695e77da94b90756eaa4b
parent588a29ff2e4e9291143d837daa6b9b5f0a9fa91c (diff)
downloaddevice-tree-compiler-430419c28100960c554cf753a5309231c03ec780.tar.gz
tests: fix some python warnings
Fixes: ResourceWarning: unclosed file <_io.BufferedReader name='test_tree1.dtb'> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20191009102025.10179-9-marcandre.lureau@redhat.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
-rw-r--r--tests/pylibfdt_tests.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/tests/pylibfdt_tests.py b/tests/pylibfdt_tests.py
index 42f31ba..509cf14 100644
--- a/tests/pylibfdt_tests.py
+++ b/tests/pylibfdt_tests.py
@@ -64,7 +64,8 @@ def _ReadFdt(fname):
Returns:
Fdt bytearray suitable for passing to libfdt functions
"""
- return libfdt.Fdt(open(fname, mode='rb').read())
+ with open(fname, mode='rb') as f:
+ return libfdt.Fdt(f.read())
class PyLibfdtBasicTests(unittest.TestCase):
"""Test class for basic pylibfdt access functions
@@ -573,7 +574,8 @@ class PyLibfdtRoTests(unittest.TestCase):
def setUp(self):
"""Read in the device tree we use for testing"""
- self.fdt = libfdt.FdtRo(open('test_tree1.dtb', mode='rb').read())
+ with open('test_tree1.dtb', mode='rb') as f:
+ self.fdt = libfdt.FdtRo(f.read())
def testAccess(self):
"""Basic sanity check for the FdtRo class"""