changeset 3937:28442c70f757

Fix conftest: Do not only create a new request per test module, but per test class/function. Fix one (broken) test. Fix double creation of TestConfig (setup() is called twice by py.test, but TestConfig must not get created twice.
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sun, 10 Aug 2008 02:18:10 +0200
parents 28a03501415a
children dd6938a4d07b a86a245db9cb bcb56b2011af
files MoinMoin/_tests/test_PageEditor.py MoinMoin/conftest.py
diffstat 2 files changed, 5 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/_tests/test_PageEditor.py	Sun Aug 10 01:09:18 2008 +0200
+++ b/MoinMoin/_tests/test_PageEditor.py	Sun Aug 10 02:18:10 2008 +0200
@@ -210,6 +210,7 @@
         """
         simple test if it is possible to delete a Dict page after creation
         """
+        become_trusted(self.request)
         pagename = u'SomeDict'
         page = PageEditor(self.request, pagename, do_editor_backup=0)
         body = u"This is an example text"
--- a/MoinMoin/conftest.py	Sun Aug 10 01:09:18 2008 +0200
+++ b/MoinMoin/conftest.py	Sun Aug 10 02:18:10 2008 +0200
@@ -170,9 +170,9 @@
 
 class MoinTestFunction(py.test.collect.Function):
     def execute(self, target, *args):
-        request = self.parent.request
         co = target.func_code
         if 'request' in co.co_varnames[:co.co_argcount]:
+            request = init_test_request()
             target(request, *args)
         else:
             target(*args)
@@ -183,8 +183,9 @@
 
     def setup(self):
         cls = self.obj
-        cls.request = self.parent.request
-        cls.TestConfig = TestConfig(cls.request)
+        if not hasattr(cls, 'request'):
+            cls.request = init_test_request()
+            cls.TestConfig = TestConfig(cls.request)
         super(MoinClassCollector, self).setup()
 
 
@@ -192,10 +193,6 @@
     Class = MoinClassCollector
     Function = MoinTestFunction
 
-    def __init__(self, *args, **kwargs):
-        self.request = init_test_request()
-        super(Module, self).__init__(*args, **kwargs)
-
     def run(self, *args, **kwargs):
         if coverage is not None:
             coverage_modules.update(getattr(self.obj, 'coverage_modules', []))