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



---
 tests/python/test_metadata_source.py |    9 ++-------
 tests/python/test_plugin.py          |    9 ++-------
 tests/python/test_registry.py        |   19 +++++++++----------
 3 files changed, 13 insertions(+), 24 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..21afe38 100644
--- a/tests/python/test_registry.py
+++ b/tests/python/test_registry.py
@@ -22,18 +22,17 @@ 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])
-
-    def tearDown(self):
-        for source in self.registry.get_sources(False):
-            self.registry.unload(source.get_id())
-            self.registry.unregister_source(source)
+        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
 
     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]