tests: Fix exception when cleaning up skipped test

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>
This commit is contained in:
Joshua Watt 2023-07-03 08:35:09 -05:00 committed by Tom Rini
parent 22cdb3f0f1
commit 8900ba1ad7
2 changed files with 4 additions and 2 deletions

View 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)

View 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)