diff mbox series

[04/12] oeqa/core/case: add file exists assertion

Message ID 20250620151429.3210879-4-ross.burton@arm.com
State New
Headers show
Series [01/12] tinfoil: add wait_for decorator and build_file_sync() helper | expand

Commit Message

Ross Burton June 20, 2025, 3:14 p.m. UTC
Add assertFileExists() to simply tests that want to check that a file
exists.

Signed-off-by: Ross Burton <ross.burton@arm.com>
---
 meta/lib/oeqa/core/case.py | 8 ++++++++
 1 file changed, 8 insertions(+)
diff mbox series

Patch

diff --git a/meta/lib/oeqa/core/case.py b/meta/lib/oeqa/core/case.py
index bc4446a938e..ad5524a7142 100644
--- a/meta/lib/oeqa/core/case.py
+++ b/meta/lib/oeqa/core/case.py
@@ -5,6 +5,7 @@ 
 #
 
 import base64
+import os
 import zlib
 import unittest
 
@@ -57,6 +58,13 @@  class OETestCase(unittest.TestCase):
             d.tearDownDecorator()
         self.tearDownMethod()
 
+    def assertFileExists(self, filename, msg=None):
+        """
+        Test that filename exists. If it does not, the test will fail.
+        """
+        if not os.path.exists(filename):
+            self.fail(msg or "%s does not exist" % filename)
+
 class OEPTestResultTestCase:
     """
     Mix-in class to provide functions to make interacting with extraresults for