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>
This commit is contained in:
parent
588a29ff2e
commit
430419c281
1 changed files with 4 additions and 2 deletions
|
@ -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"""
|
||||
|
|
Loading…
Reference in a new issue