Re: [PATCH v2 08/10] tests: fix some python warnings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



On Wed, Oct 09, 2019 at 02:20:23PM +0400, marcandre.lureau@xxxxxxxxxx wrote:
> From: Marc-André Lureau <marcandre.lureau@xxxxxxxxxx>
> 
> Fixes:
> ResourceWarning: unclosed file <_io.BufferedReader name='test_tree1.dtb'>
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@xxxxxxxxxx>

Applied, thanks.

> ---
>  tests/pylibfdt_tests.py | 6 ++++--
>  1 file 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"""

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Device Tree]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux