[gnome-continuous-yocto/gnomeostree-3.28-rocko: 5981/8267] base.py: add assertExists and assertNotExists to oeselftest
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-continuous-yocto/gnomeostree-3.28-rocko: 5981/8267] base.py: add assertExists and assertNotExists to oeselftest
- Date: Sun, 17 Dec 2017 04:12:07 +0000 (UTC)
commit 61b2aef03a1e7b6a0e467a54cc0bd411ab3fc6ad
Author: Yeoh Ee Peng <ee peng yeoh intel com>
Date: Sun May 21 11:22:22 2017 -0700
base.py: add assertExists and assertNotExists to oeselftest
Current osselftest print confusing assertion message when using
self.assertTrue(os.path.exists(filepath)) to test file path,
example of confusing assertion message:
AssertionError: False is not true
Add the assertExists and assertNotExists to improve assertion
message and simplify coding, using selft.assertExists(filepath),
will print meaningful assertion message:
AssertionError: <filepath> does not exist
[YOCTO #11356]
(From OE-Core rev: b0a74554ef926ce05078494ca8e67178b56232f5)
Signed-off-by: Yeoh Ee Peng <ee peng yeoh intel com>
Signed-off-by: Ross Burton <ross burton intel com>
Signed-off-by: Richard Purdie <richard purdie linuxfoundation org>
meta/lib/oeqa/selftest/base.py | 13 +++++++++++++
1 files changed, 13 insertions(+), 0 deletions(-)
---
diff --git a/meta/lib/oeqa/selftest/base.py b/meta/lib/oeqa/selftest/base.py
index 47a8ea8..43a1951 100644
--- a/meta/lib/oeqa/selftest/base.py
+++ b/meta/lib/oeqa/selftest/base.py
@@ -18,6 +18,7 @@ from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_test_layer
from oeqa.utils.decorators import LogResults
from random import choice
import glob
+from unittest.util import safe_repr
@LogResults
class oeSelfTest(unittest.TestCase):
@@ -214,6 +215,18 @@ be re-executed from a clean environment to ensure accurate results.")
self.log.debug("Writing to: %s\n%s\n" % (self.machineinc_path, data))
ftools.write_file(self.machineinc_path, data)
+ # check does path exist
+ def assertExists(self, expr, msg=None):
+ if not os.path.exists(expr):
+ msg = self._formatMessage(msg, "%s does not exist" % safe_repr(expr))
+ raise self.failureException(msg)
+
+ # check does path not exist
+ def assertNotExists(self, expr, msg=None):
+ if os.path.exists(expr):
+ msg = self._formatMessage(msg, "%s exists when it should not" % safe_repr(expr))
+ raise self.failureException(msg)
+
def get_available_machines():
# Get a list of all available machines
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]