Patchwork [1/3] test-utils: handle import bb failing and skip the test

login
register
mail settings
Submitter Ross Burton
Date May 23, 2013, 6:44 p.m.
Message ID <1369334701-18752-1-git-send-email-ross.burton@intel.com>
Download mbox | patch
Permalink /patch/50417/
State Accepted
Commit a32d16cb2971e3096ecb2333e672ad198c3cfe46
Headers show

Comments

Ross Burton - May 23, 2013, 6:44 p.m.
Instead of reporting an error when bb cannot be imported, skip the test
instead. This makes it a lot easier to iterate a test suite when we don't care
about this particular test.

Signed-off-by: Ross Burton <ross.burton@intel.com>
---
 meta/lib/oe/tests/test_utils.py |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
Richard Purdie - May 30, 2013, 7:49 p.m.
On Thu, 2013-05-23 at 19:44 +0100, Ross Burton wrote:
> Instead of reporting an error when bb cannot be imported, skip the test
> instead. This makes it a lot easier to iterate a test suite when we don't care
> about this particular test.
> 
> Signed-off-by: Ross Burton <ross.burton@intel.com>
> ---
>  meta/lib/oe/tests/test_utils.py |    6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/meta/lib/oe/tests/test_utils.py b/meta/lib/oe/tests/test_utils.py
> index 466c47e..779247a 100644
> --- a/meta/lib/oe/tests/test_utils.py
> +++ b/meta/lib/oe/tests/test_utils.py
> @@ -1,11 +1,15 @@
>  import unittest
> -import bb, oe.utils
> +import oe.utils
>  
>  class TestPackagesFilterOutSystem(unittest.TestCase):
>      def test_filter(self):
>          """
>          Test that oe.utils.packages_filter_out_system works.
>          """
> +        try:
> +            import bb
> +        except ImportError:
> +            self.skipTest("Cannot import bb")
>  
>          d = bb.data_smart.DataSmart()
>          d.setVar("PN", "foo")

This a python 2.7ism :(

For various reasons we should really add unittest from python 2.7 into
bitbake and solve this problem that way once and for all. I appreciate
that adds a hard dependency on using bitbake but OE isn't much use
without it...

Cheers,

Richard

Patch

diff --git a/meta/lib/oe/tests/test_utils.py b/meta/lib/oe/tests/test_utils.py
index 466c47e..779247a 100644
--- a/meta/lib/oe/tests/test_utils.py
+++ b/meta/lib/oe/tests/test_utils.py
@@ -1,11 +1,15 @@ 
 import unittest
-import bb, oe.utils
+import oe.utils
 
 class TestPackagesFilterOutSystem(unittest.TestCase):
     def test_filter(self):
         """
         Test that oe.utils.packages_filter_out_system works.
         """
+        try:
+            import bb
+        except ImportError:
+            self.skipTest("Cannot import bb")
 
         d = bb.data_smart.DataSmart()
         d.setVar("PN", "foo")