]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
tests: Fix exception when cleaning up skipped test
authorJoshua Watt <jpewhacker@gmail.com>
Mon, 3 Jul 2023 13:35:09 +0000 (08:35 -0500)
committerTom Rini <trini@konsulko.com>
Mon, 17 Jul 2023 19:39:55 +0000 (15:39 -0400)
If test_cat and test_xxd cannot create the required file, the test will
be skipped, but this would result in an exception being raised in the
finally block because the file didn't exist to be cleaned up. This
caused the test to be marked as failed instead of skipped.

Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
test/py/tests/test_cat/conftest.py
test/py/tests/test_xxd/conftest.py

index fc396f50d3262e14130118c46649e8692295e2a3..320e7ebd295fc9d458f07f0c2cf9b9b906321986 100644 (file)
@@ -32,4 +32,5 @@ def cat_data(u_boot_config):
         pytest.skip('Setup failed')
     finally:
         shutil.rmtree(mnt_point)
-        os.remove(image_path)
+        if os.path.exists(image_path):
+            os.remove(image_path)
index f35b8f111362b1cd936bf9d85ab680cfe67043fc..47c7cce1aa9f8688e3597abb6a1ed80ee1282a41 100644 (file)
@@ -32,4 +32,5 @@ def xxd_data(u_boot_config):
         pytest.skip('Setup failed')
     finally:
         shutil.rmtree(mnt_point)
-        os.remove(image_path)
+        if os.path.exists(image_path):
+            os.remove(image_path)