[OE-core] [PATCH 2/2] selftest/oeselftest: add QA test for assertExists and assertNotExists
Yeoh Ee Peng
ee.peng.yeoh at intel.com
Sun May 21 18:22:23 UTC 2017
Add QA tests for assertExists and assertNotExists inside osSelfTest class.
Add positive and negative testing for each assert function.
[YOCTO #11356]
Signed-off-by: Yeoh Ee Peng <ee.peng.yeoh at intel.com>
---
meta/lib/oeqa/selftest/oeselftest.py | 35 +++++++++++++++++++++++++++++++++++
1 file changed, 35 insertions(+)
create mode 100644 meta/lib/oeqa/selftest/oeselftest.py
diff --git a/meta/lib/oeqa/selftest/oeselftest.py b/meta/lib/oeqa/selftest/oeselftest.py
new file mode 100644
index 0000000..b26f85c
--- /dev/null
+++ b/meta/lib/oeqa/selftest/oeselftest.py
@@ -0,0 +1,35 @@
+from oeqa.selftest.base import oeSelfTest
+
+class OeSelfTest(oeSelfTest):
+
+ def test_oeselftest_assertexists_does_raise_exception(self):
+ tc = oeSelfTest(methodName='assertExists')
+ cur_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'Wrong')
+
+ with self.assertRaises(AssertionError) as cm:
+ tc.assertExists(cur_path)
+
+ def test_oeselftest_assertexists_does_not_raise_exception(self):
+ tc = oeSelfTest(methodName='assertExists')
+ cur_path = os.path.dirname(os.path.realpath(__file__))
+
+ try:
+ tc.assertExists(cur_path)
+ except:
+ self.assertTrue(False, 'It raise exception where it should not')
+
+ def test_oeselftest_assertnotexists_does_raise_exception(self):
+ tc = oeSelfTest(methodName='assertExists')
+ cur_path = os.path.dirname(os.path.realpath(__file__))
+
+ with self.assertRaises(AssertionError) as cm:
+ tc.assertNotExists(cur_path)
+
+ def test_oeselftest_assertnotexists_does_not_raise_exception(self):
+ tc = oeSelfTest(methodName='assertExists')
+ cur_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'XXX')
+
+ try:
+ tc.assertNotExists(cur_path)
+ except:
+ self.assertTrue(False, 'It raise exception where it should not')
--
2.7.4
More information about the Openembedded-core
mailing list