public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [PATCH] tests: Fix exception when cleaning up skipped test
@ 2023-07-03 13:35 Joshua Watt
  2023-07-04  2:40 ` Simon Glass
  2023-07-18 13:58 ` Tom Rini
  0 siblings, 2 replies; 3+ messages in thread
From: Joshua Watt @ 2023-07-03 13:35 UTC (permalink / raw)
  To: u-boot; +Cc: Joshua Watt, Roger Knecht, Simon Glass

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>
---
 test/py/tests/test_cat/conftest.py | 3 ++-
 test/py/tests/test_xxd/conftest.py | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/test/py/tests/test_cat/conftest.py b/test/py/tests/test_cat/conftest.py
index 058fe52352..ef1c54d513 100644
--- a/test/py/tests/test_cat/conftest.py
+++ b/test/py/tests/test_cat/conftest.py
@@ -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)
diff --git a/test/py/tests/test_xxd/conftest.py b/test/py/tests/test_xxd/conftest.py
index 59285aadf4..481a794961 100644
--- a/test/py/tests/test_xxd/conftest.py
+++ b/test/py/tests/test_xxd/conftest.py
@@ -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)
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-07-18 13:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-03 13:35 [PATCH] tests: Fix exception when cleaning up skipped test Joshua Watt
2023-07-04  2:40 ` Simon Glass
2023-07-18 13:58 ` Tom Rini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox