tests: Fix exception when cleaning up skipped test
PATCH 1/1 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.
--- test/py/tests/test_cat/conftest.py | 3 ++- test/py/tests/test_xxd/conftest.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-)
test/py/tests/test_cat/conftest.py +2 -1
@@ -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)
test/py/tests/test_xxd/conftest.py +2 -1
@@ -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)
Signature · 1 line
2.33.0
Quoted 11 lines · Joshua Watt
If
test_catandtest_xxdcannot 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 <[email protected]>--- test/py/tests/test_cat/conftest.py | 3 ++- test/py/tests/test_xxd/conftest.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-)
Quoted 7 lines · Joshua Watt
If
test_catandtest_xxdcannot 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 <[email protected]>Reviewed-by Simon Glass <[email protected]>
Applied to u-boot/master, thanks!
Signature · 1 line
Tom