changeset 585:6610f364cfae pytest2

init_test_app and deinit_test_app removed from all the tests of storage module. This can be done in conftest.py itself.
author pkumar <contactprashantat@gmail.com>
date Wed, 22 Jun 2011 00:33:06 +0530
parents fefd0baf5c89
children efc0fcd76f43
files MoinMoin/conftest.py MoinMoin/storage/_tests/test_backends_fs2.py MoinMoin/storage/_tests/test_backends_memory.py MoinMoin/storage/_tests/test_backends_router.py
diffstat 4 files changed, 10 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/conftest.py	Tue Jun 21 19:18:08 2011 +0530
+++ b/MoinMoin/conftest.py	Wed Jun 22 00:33:06 2011 +0530
@@ -90,13 +90,18 @@
                     self.app, self.ctx = init_test_app(given_config)
                 else:
                     given_config = wikiconfig.Config
-                    # deinit the previous app if previous class had its own configuration 
-                    if hasattr(prev_cls, 'Config'):
-                        deinit_test_app(prev_app, prev_ctx)        
+                    # deinit the previous app if previous class had its own configuration
+                    # deinit the previous app if the class of previous function has an attribute 'create_backend' 
+                    # this is for the tests of storage module until we use some cleanup mechanism on tests.
+                    if hasattr(prev_cls, 'Config') or hasattr(prev_cls, 'create_backend'):
+                        deinit_test_app(prev_app, prev_ctx)
+                        print "problem is here"        
                     # Initialize the app in following two conditions: 
                     # 1. It is the first test item 
                     # 2. Class of previous function item had its own configuration i.e. hasattr(cls, Config)
-                    if prev_app == None or hasattr(prev_cls, 'Config'):
+                    # Also if the Class of previous function is having an attribute as 'create_backend', 
+                    # this is for the tests of storage module until we use some cleanup mechanism on tests.
+                    if prev_app == None or hasattr(prev_cls, 'Config') or hasattr(prev_cls, 'create_backend'):
                         self.app, self.ctx = init_test_app(given_config)
                     # continue assigning the values of the previous app and ctx to the current ones.
                     else:
--- a/MoinMoin/storage/_tests/test_backends_fs2.py	Tue Jun 21 19:18:08 2011 +0530
+++ b/MoinMoin/storage/_tests/test_backends_fs2.py	Wed Jun 22 00:33:06 2011 +0530
@@ -12,18 +12,13 @@
 from MoinMoin.storage.backends.fs2 import FS2Backend
 from MoinMoin.storage.backends.router import RouterBackend
 
-from MoinMoin.conftest import init_test_app, deinit_test_app
-from MoinMoin._tests import wikiconfig
 class TestFS2Backend(BackendTest):
 
     def create_backend(self):
-        # temporary hack till we use some cleanup mechnism on tests.
-        self.app, self.ctx = init_test_app(wikiconfig.Config)
         self.tempdir = tempfile.mkdtemp('', 'moin-')
         return RouterBackend([('/', FS2Backend(self.tempdir))], index_uri='sqlite://')
 
     def kill_backend(self):
-        deinit_test_app(self.app, self.ctx)
         try:
             for root, dirs, files in os.walk(self.tempdir):
                 for d in dirs:
--- a/MoinMoin/storage/_tests/test_backends_memory.py	Tue Jun 21 19:18:08 2011 +0530
+++ b/MoinMoin/storage/_tests/test_backends_memory.py	Wed Jun 22 00:33:06 2011 +0530
@@ -12,31 +12,24 @@
 
 from MoinMoin.storage._tests.test_backends import BackendTest
 from MoinMoin.storage.backends.memory import MemoryBackend, TracingBackend
-from MoinMoin.conftest import init_test_app, deinit_test_app
-from MoinMoin._tests import wikiconfig
+
 class TestMemoryBackend(BackendTest):
     """
     Test the MemoryBackend
     """
 
     def create_backend(self):
-        # temporary hack till we apply some cleanup mechanism on tests         
-        self.app, self.ctx = init_test_app(wikiconfig.Config)
         return MemoryBackend()
 
     def kill_backend(self):
-        deinit_test_app(self.app, self.ctx)
         pass
 
 class TestTracingBackend(BackendTest):
     def create_backend(self):
-        # temporary hack till we apply some cleanup mechanism on tests         
-        self.app, self.ctx = init_test_app(wikiconfig.Config)
         import random
         return TracingBackend()#"/tmp/codebuf%i.py" % random.randint(1, 2**30))
 
     def kill_backend(self):
-        deinit_test_app(self.app, self.ctx)
         func = self.backend.get_func()
         try:
             func(MemoryBackend()) # should not throw any exc
--- a/MoinMoin/storage/_tests/test_backends_router.py	Tue Jun 21 19:18:08 2011 +0530
+++ b/MoinMoin/storage/_tests/test_backends_router.py	Wed Jun 22 00:33:06 2011 +0530
@@ -16,8 +16,6 @@
 from MoinMoin.storage._tests.test_backends import BackendTest
 from MoinMoin.storage.backends.memory import MemoryBackend
 from MoinMoin.storage.backends.router import RouterBackend
-from MoinMoin.conftest import init_test_app, deinit_test_app
-from MoinMoin._tests import wikiconfig
 
 class TestRouterBackend(BackendTest):
     """
@@ -25,8 +23,6 @@
     """
 
     def create_backend(self):
-        # temporary hack till we get some cleanup mechanism for the tests 
-        self.app, self.ctx = init_test_app(wikiconfig.Config)
         self.root = MemoryBackend()
         self.ns_user_profile = app.cfg.ns_user_profile
         self.users = MemoryBackend()
@@ -36,7 +32,6 @@
         return RouterBackend(self.mapping, index_uri='sqlite://')
 
     def kill_backend(self):
-        deinit_test_app(self.app, self.ctx)
         pass