[PATCH 7/7] tests: Removed setUp/tearDown code in python tests



setUp/tearDown methods in the tests load and unload the plugins
so that each test is run in a clean environment.

However, the current plugin mechanism doesn't allow that, and reloading
a previously loaded/unloaded plugin produces a crash. This patch
removes setUp/tearDown code, adding the plugin load in the tests constructor
but leaving the plugins loaded during all the test suite execution. While
this is a fix which allows the tests to be run, some of them will fail.

Once that the plugin system is reworked to allow unloading/reloading, this
commit should be reverted to come back to the original behavior.
---
 tests/python/test_metadata_source.py |    9 ++-------
 tests/python/test_plugin.py          |    9 ++-------
 tests/python/test_registry.py        |   22 ++++++++++++++--------
 3 files changed, 18 insertions(+), 22 deletions(-)

diff --git a/tests/python/test_metadata_source.py b/tests/python/test_metadata_source.py
index 92482e7..27cf58a 100644
--- a/tests/python/test_metadata_source.py
+++ b/tests/python/test_metadata_source.py
@@ -13,7 +13,8 @@ class TestMetadataSource(unittest.TestCase):
     METADATA_FLAGS = Grl.MetadataResolutionFlags(Grl.MetadataResolutionFlags.FULL |
                                                  Grl.MetadataResolutionFlags.IDLE_RELAY)
 
-    def setUp(self):
+    def __init__(self, method_name):
+        super(TestMetadataSource, self).__init__(method_name)
         Grl.init([])
         self.registry = Grl.PluginRegistry.get_default()
         self.registry.load_all()
@@ -23,12 +24,6 @@ class TestMetadataSource(unittest.TestCase):
         if sources:
             self.metadata_source = sources[0]
 
-    def tearDown(self):
-        self.metadata_source = None
-        for source in self.registry.get_sources(False):
-            self.registry.unload(source.get_id())
-            self.registry.unregister_source(source)
-
     def test_supported_ops(self):
         ops = self.metadata_source.supported_operations()
         self.assertTrue(ops)
diff --git a/tests/python/test_plugin.py b/tests/python/test_plugin.py
index 1af54cb..9ebc6c7 100644
--- a/tests/python/test_plugin.py
+++ b/tests/python/test_plugin.py
@@ -11,7 +11,8 @@ class TestMediaPlugin(unittest.TestCase):
 
     NONEXISTING_KEY = 'nonexisting_key'
 
-    def setUp(self):
+    def __init__(self, method_name):
+        super(TestMediaPlugin, self).__init__(method_name)
         Grl.init([])
         self.registry = Grl.PluginRegistry.get_default()
         self.registry.load_all()
@@ -19,12 +20,6 @@ class TestMediaPlugin(unittest.TestCase):
         if sources:
             self.plugin = sources[0]
 
-    def tearDown(self):
-        self.plugin = None
-        for source in self.registry.get_sources(False):
-            self.registry.unload(source.get_id())
-            self.registry.unregister_source(source)
-
     def test_get_name(self):
         name = self.plugin.get_name()
         self.assertTrue(name)
diff --git a/tests/python/test_registry.py b/tests/python/test_registry.py
index b7b85c1..06b072f 100644
--- a/tests/python/test_registry.py
+++ b/tests/python/test_registry.py
@@ -22,18 +22,24 @@ class TestPluginRegistry(unittest.TestCase):
 
     NONEXISTING_SOURCE = 'NON_EXISTING_SOURCE'
 
-    def setUp(self):
+    def __init__(self, method_name):
+        super(TestPluginRegistry, self).__init__(method_name)
         Grl.init([])
         self.registry = Grl.PluginRegistry.get_default()
-        plugin_dir = os.listdir(util.GRL_PLUGIN_PATH)
-        if plugin_dir:
-            self.EXISTING_LIBRARY_PATH = os.path.join(util.GRL_PLUGIN_PATH,
-                                                      plugin_dir[0])
+        plugin_paths = util.GRL_PLUGIN_PATH.split(':')
+        for path in plugin_paths:
+            if path:
+                entries = os.listdir(path)
+                self.EXISTING_LIBRARY_PATH = os.path.join(path,
+                                                          entries[0])
+                break
+        print self.EXISTING_LIBRARY_PATH
+
+    def setUp(self):
+        pass
 
     def tearDown(self):
-        for source in self.registry.get_sources(False):
-            self.registry.unload(source.get_id())
-            self.registry.unregister_source(source)
+        pass
 
     def test_get_default_not_null(self):
         registry = Grl.PluginRegistry.get_default()
-- 
1.7.0.4



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]