summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/core/utils/test.py
diff options
context:
space:
mode:
authorMariano Lopez <mariano.lopez@linux.intel.com>2016-11-09 10:33:42 -0600
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-01-23 12:03:52 +0000
commit102d04ccca3ca89d41b76a8c44e0ca0f436b7004 (patch)
treee8e71f317fa888a8a9434ef9250f2db3b19a719d /meta/lib/oeqa/core/utils/test.py
parentc466086ccc4d4bb02d578a821cfb945945bfd529 (diff)
downloadopenembedded-core-contrib-102d04ccca3ca89d41b76a8c44e0ca0f436b7004.tar.gz
oeqa/core: Add utils module for OEQA framework
misc: Functions for transform object to other types. path: Functions for path handling. test: Functions for operations related to test cases and suites. [YOCTO #10232] Signed-off-by: Mariano Lopez <mariano.lopez@linux.intel.com> Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com>
Diffstat (limited to 'meta/lib/oeqa/core/utils/test.py')
-rw-r--r--meta/lib/oeqa/core/utils/test.py71
1 files changed, 71 insertions, 0 deletions
diff --git a/meta/lib/oeqa/core/utils/test.py b/meta/lib/oeqa/core/utils/test.py
new file mode 100644
index 0000000000..820b9976ab
--- /dev/null
+++ b/meta/lib/oeqa/core/utils/test.py
@@ -0,0 +1,71 @@
+# Copyright (C) 2016 Intel Corporation
+# Released under the MIT license (see COPYING.MIT)
+
+import os
+import unittest
+
+def getSuiteCases(suite):
+ """
+ Returns individual test from a test suite.
+ """
+ tests = []
+ for item in suite:
+ if isinstance(item, unittest.suite.TestSuite):
+ tests.extend(getSuiteCases(item))
+ elif isinstance(item, unittest.TestCase):
+ tests.append(item)
+ return tests
+
+def getSuiteModules(suite):
+ """
+ Returns modules in a test suite.
+ """
+ modules = set()
+ for test in getSuiteCases(suite):
+ modules.add(getCaseModule(test))
+ return modules
+
+def getSuiteCasesInfo(suite, func):
+ """
+ Returns test case info from suite. Info is fetched from func.
+ """
+ tests = []
+ for test in getSuiteCases(suite):
+ tests.append(func(test))
+ return tests
+
+def getSuiteCasesNames(suite):
+ """
+ Returns test case names from suite.
+ """
+ return getSuiteCasesInfo(suite, getCaseMethod)
+
+def getSuiteCasesIDs(suite):
+ """
+ Returns test case ids from suite.
+ """
+ return getSuiteCasesInfo(suite, getCaseID)
+
+def getCaseModule(test_case):
+ """
+ Returns test case module name.
+ """
+ return test_case.__module__
+
+def getCaseClass(test_case):
+ """
+ Returns test case class name.
+ """
+ return test_case.__class__.__name__
+
+def getCaseID(test_case):
+ """
+ Returns test case complete id.
+ """
+ return test_case.id()
+
+def getCaseMethod(test_case):
+ """
+ Returns test case method name.
+ """
+ return getCaseID(test_case).split('.')[-1]