Re: [PATCH 1/1] binman: used-before-assignment in ftest.py

2024-01-01 Thread Simon Glass
On Fri, 15 Dec 2023 at 16:26, Heinrich Schuchardt
 wrote:
>
> Pytest 7.4.3 complains if a variable is used in a finally clause without
> having been initialized before the try clause.
>
> Signed-off-by: Heinrich Schuchardt 
> ---
>  tools/binman/ftest.py | 20 +++-
>  1 file changed, 15 insertions(+), 5 deletions(-)
>

Reviewed-by: Simon Glass 

Applied to u-boot-dm/next, thanks!


Re: [PATCH 1/1] binman: used-before-assignment in ftest.py

2023-12-16 Thread Simon Glass
On Fri, 15 Dec 2023 at 16:26, Heinrich Schuchardt
 wrote:
>
> Pytest 7.4.3 complains if a variable is used in a finally clause without
> having been initialized before the try clause.
>
> Signed-off-by: Heinrich Schuchardt 
> ---
>  tools/binman/ftest.py | 20 +++-
>  1 file changed, 15 insertions(+), 5 deletions(-)
>

Reviewed-by: Simon Glass 


[PATCH 1/1] binman: used-before-assignment in ftest.py

2023-12-15 Thread Heinrich Schuchardt
Pytest 7.4.3 complains if a variable is used in a finally clause without
having been initialized before the try clause.

Signed-off-by: Heinrich Schuchardt 
---
 tools/binman/ftest.py | 20 +++-
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
index a273120d9f..a4ac520cbb 100644
--- a/tools/binman/ftest.py
+++ b/tools/binman/ftest.py
@@ -2842,12 +2842,14 @@ class TestFunctional(unittest.TestCase):
 fdt_size = entries['section'].GetEntries()['u-boot-dtb'].size
 fdtmap_offset = entries['fdtmap'].offset
 
+tmpdir = None
 try:
 tmpdir, updated_fname = self._SetupImageInTmpdir()
 with test_util.capture_sys_output() as (stdout, stderr):
 self._DoBinman('ls', '-i', updated_fname)
 finally:
-shutil.rmtree(tmpdir)
+if tmpdir:
+shutil.rmtree(tmpdir)
 lines = stdout.getvalue().splitlines()
 expected = [
 'Name  Image-pos  Size  Entry-typeOffset  Uncomp-size',
@@ -2868,12 +2870,14 @@ class TestFunctional(unittest.TestCase):
 def testListCmdFail(self):
 """Test failing to list an image"""
 self._DoReadFile('005_simple.dts')
+tmpdir = None
 try:
 tmpdir, updated_fname = self._SetupImageInTmpdir()
 with self.assertRaises(ValueError) as e:
 self._DoBinman('ls', '-i', updated_fname)
 finally:
-shutil.rmtree(tmpdir)
+if tmpdir:
+shutil.rmtree(tmpdir)
 self.assertIn("Cannot find FDT map in image", str(e.exception))
 
 def _RunListCmd(self, paths, expected):
@@ -3002,13 +3006,15 @@ class TestFunctional(unittest.TestCase):
 self._CheckLz4()
 self._DoReadFileRealDtb('130_list_fdtmap.dts')
 fname = os.path.join(self._indir, 'output.extact')
+tmpdir = None
 try:
 tmpdir, updated_fname = self._SetupImageInTmpdir()
 with test_util.capture_sys_output() as (stdout, stderr):
 self._DoBinman('extract', '-i', updated_fname, 'u-boot',
'-f', fname)
 finally:
-shutil.rmtree(tmpdir)
+if tmpdir:
+shutil.rmtree(tmpdir)
 data = tools.read_file(fname)
 self.assertEqual(U_BOOT_DATA, data)
 
@@ -5185,12 +5191,14 @@ fdt fdtmapExtract the 
devicetree blob from the fdtmap
 data = self._DoReadFileRealDtb('207_fip_ls.dts')
 hdr, fents = fip_util.decode_fip(data)
 
+tmpdir = None
 try:
 tmpdir, updated_fname = self._SetupImageInTmpdir()
 with test_util.capture_sys_output() as (stdout, stderr):
 self._DoBinman('ls', '-i', updated_fname)
 finally:
-shutil.rmtree(tmpdir)
+if tmpdir:
+shutil.rmtree(tmpdir)
 lines = stdout.getvalue().splitlines()
 expected = [
 'NameImage-pos  Size  Entry-type  Offset  Uncomp-size',
@@ -5395,12 +5403,14 @@ fdt fdtmapExtract the 
devicetree blob from the fdtmap
 use_real_dtb=True,
 extra_indirs=[os.path.join(self._indir, TEST_FDT_SUBDIR)])
 
+tmpdir = None
 try:
 tmpdir, updated_fname = self._SetupImageInTmpdir()
 with test_util.capture_sys_output() as (stdout, stderr):
 self._RunBinman('ls', '-i', updated_fname)
 finally:
-shutil.rmtree(tmpdir)
+if tmpdir:
+shutil.rmtree(tmpdir)
 
 def testFitSubentryUsesBintool(self):
 """Test that binman FIT subentries can use bintools"""
-- 
2.40.1