[oe-commits] [openembedded-core] 01/06: oescripts.py: use unittest.SkipUnless for class skip

git at git.openembedded.org git at git.openembedded.org
Wed Jan 22 15:57:22 UTC 2020


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 1923b90dfe72473077190a7a8fa0ac274ec7fdd5
Author: Trevor Gamblin <trevor.gamblin at windriver.com>
AuthorDate: Thu Dec 5 11:55:19 2019 -0500

    oescripts.py: use unittest.SkipUnless for class skip
    
    Yocto Bug: https://bugzilla.yoctoproject.org/show_bug.cgi?id=13663
    
    Prior to this fix, the try/except block in OEScriptTests' setUpClass
    did both the import and the raise unittest.SkipTest for the
    subsequent OEPybootchartguyTests. The consequence of the this meant
    that, when cairo was not available on the test host, the raise was
    counted only once as a class setup issue, instead of once for each
    of the tests to be run, resulting in incorrect skip counts in the
    test results.
    
    Instead of raising unittest.SkipTest in setUpClass, the more
    proper method is to use the unittest.skipUnless method along with
    importlib.util.find_spec to check for the presence of the
    python3-cairo module. This allows the entire class to be skipped
    if cairo is not present, while also correctly passing along the
    skip state for each of the class's tests, and avoiding the UNKNOWN
    results to appear in cases where the -j option was provided to
    oe-selftest, but the tests were still skipped.
    
    Signed-off-by: Trevor Gamblin <trevor.gamblin at windriver.com>
    Signed-off-by: Ross Burton <ross.burton at intel.com>
---
 meta/lib/oeqa/selftest/cases/oescripts.py | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/meta/lib/oeqa/selftest/cases/oescripts.py b/meta/lib/oeqa/selftest/cases/oescripts.py
index 41cbe04..2f18d8f 100644
--- a/meta/lib/oeqa/selftest/cases/oescripts.py
+++ b/meta/lib/oeqa/selftest/cases/oescripts.py
@@ -4,6 +4,7 @@
 
 import os
 import shutil
+import importlib
 import unittest
 from oeqa.selftest.case import OESelftestTestCase
 from oeqa.selftest.cases.buildhistory import BuildhistoryBase
@@ -33,15 +34,13 @@ class BuildhistoryDiffTests(BuildhistoryBase):
         if expected_endlines:
             self.fail('Missing expected line endings:\n  %s' % '\n  '.join(expected_endlines))
 
+ at unittest.skipUnless(importlib.util.find_spec("cairo"), "Python cairo module is not present")
 class OEScriptTests(OESelftestTestCase):
 
     @classmethod
     def setUpClass(cls):
         super(OEScriptTests, cls).setUpClass()
-        try:
-            import cairo
-        except ImportError:
-            raise unittest.SkipTest('Python module cairo is not present')
+        import cairo
         bitbake("core-image-minimal -c rootfs -f")
         cls.tmpdir = get_bb_var('TMPDIR')
         cls.buildstats = cls.tmpdir + "/buildstats/" + sorted(os.listdir(cls.tmpdir + "/buildstats"))[-1]

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


More information about the Openembedded-commits mailing list