[oe-commits] [openembedded-core] 02/28: oeqa/core/loader: Generate function _make_failed_test dynamically

git at git.openembedded.org git at git.openembedded.org
Thu Jul 20 09:44:22 UTC 2017


This is an automated email from the git hooks/post-receive script.

rpurdie pushed a commit to branch master-next
in repository openembedded-core.

commit 39a2f054573bddf116b4cdd0016746c54e593805
Author: Aníbal Limón <anibal.limon at linux.intel.com>
AuthorDate: Thu Jun 29 15:02:14 2017 -0500

    oeqa/core/loader: Generate function _make_failed_test dynamically
    
    Python versions has different features from branches 3.4.x, 3.5.x and
    3.6.x, i expected in wrong mode that was incremental for example changes
    in 3.4.4 be in 3.5.x but that's not true.
    
    The _make_failed_test internal method differs and is only available in
    certain versions >= 3.4.4 and in 3.5.x and 3.6.x branches but not
    realeses have been made including it.
    
    So to avoid futher problems inspect the _make_failed_test and generates
    function definition according what parameters are needed, the unique
    supossition is that exception argument is always passed.
    
    Related to,
    http://git.yoctoproject.org/cgit/cgit.cgi/poky/commit/?id=d8380d098a290510b442a7abd2dd5a50cabf5844
    
    Signed-off-by: Aníbal Limón <anibal.limon at linux.intel.com>
---
 meta/lib/oeqa/core/loader.py | 25 ++++++++++++-------------
 1 file changed, 12 insertions(+), 13 deletions(-)

diff --git a/meta/lib/oeqa/core/loader.py b/meta/lib/oeqa/core/loader.py
index 80e3d28..e4c218b 100644
--- a/meta/lib/oeqa/core/loader.py
+++ b/meta/lib/oeqa/core/loader.py
@@ -4,6 +4,7 @@
 import os
 import sys
 import unittest
+import inspect
 
 from oeqa.core.utils.path import findFile
 from oeqa.core.utils.test import getSuiteModules, getCaseID
@@ -12,19 +13,17 @@ from oeqa.core.case import OETestCase
 from oeqa.core.decorator import decoratorClasses, OETestDecorator, \
         OETestFilter, OETestDiscover
 
-if sys.version_info >= (3,4,4):
-    def _make_failed_test(classname, methodname, exception, suiteClass):
-        """
-            When loading tests, the unittest framework stores any exceptions and
-            displays them only when the 'run' method is called.
-
-            For our purposes, it is better to raise the exceptions in the loading
-            step rather than waiting to run the test suite.
-        """
-        raise exception
-else:
-    def _make_failed_test(classname, exception, suiteClass):
-        raise exception
+# When loading tests, the unittest framework stores any exceptions and
+# displays them only when the run method is called.
+#
+# For our purposes, it is better to raise the exceptions in the loading
+# step rather than waiting to run the test suite.
+#
+# Generate the function definition because this differ across python versions
+# Python >= 3.4.4 uses tree parameters instead four but for example Python 3.5.3
+# ueses four parameters so isn't incremental.
+_failed_test_args = inspect.getargspec(unittest.loader._make_failed_test).args
+exec("""def _make_failed_test(%s): raise exception""" % ', '.join(_failed_test_args))
 unittest.loader._make_failed_test = _make_failed_test
 
 def _find_duplicated_modules(suite, directory):

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Openembedded-commits mailing list