changeset 71:a5cf73110f17

fix all ERRORS in test_conventer_who_invented_that_impossible_name, 53 tests fail imported from: moin--main--1.5--patch-73
author Nir Soffer <nirs@freeshell.org>
date Mon, 03 Oct 2005 21:42:56 +0000
parents 36a2541550aa
children 384983d5ca1e
files MoinMoin/_tests/test_converter_text_html_text_x_moin.py
diffstat 1 files changed, 38 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/_tests/test_converter_text_html_text_x_moin.py	Mon Oct 03 20:42:12 2005 +0000
+++ b/MoinMoin/_tests/test_converter_text_html_text_x_moin.py	Mon Oct 03 21:42:56 2005 +0000
@@ -5,11 +5,20 @@
 
 import MoinMoin.converter.text_html_text_x_moin as converter
 import MoinMoin.parser.wiki, MoinMoin.formatter.text_gedit, MoinMoin.request
+from MoinMoin import _tests
+
 convert = converter.convert
 error = converter.ConvertError
 
 
 class BaseTestCase(unittest.TestCase):
+
+    def setUp(self):
+        self.cfg = _tests.TestConfig(self.request, bang_meta=True)
+        
+    def tearDown(self):
+        del self.cfg
+
     def do_convert_real(self, func_args, successfull = True):
         try:
             ret = convert(*func_args)
@@ -23,43 +32,51 @@
         else:
             self.fail("don't fail with parse error")
 
-class MinimalConfig(object):
-    def __init__(self):
-        self.bang_meta = True
-        self.siteid = 'test'
 
 class MinimalPage(object):
     def __init__(self):
         self.hilite_re = None
         self.page_name = "testpage"
 
+
 class MinimalRequest(object):
-    def __init__(self):
-        self.cfg = MinimalConfig()
+    # TODO: do we really need this class? no other test use a request
+    # replacement.
+
+    def __init__(self, request):
+        self.request = request
         self.clock = MoinMoin.request.Clock()
+        
+        # This is broken - tests that need correct content_lang will fail
         self.content_lang = None
         self.current_lang = None
+        
         self.form = {}
         self._page_headings = {}
         self.result = []
 
-    def getText(self, text):
+    def getText(self, text, formatted=True):
         return text
 
     def write(self, text):
         self.result.append(text)
 
+    def __getattr__(self, name):
+        return getattr(self.request, name)
+
+
 class ConvertBlockRepeatableTestCase(BaseTestCase):
     def do(self, text, output):
         text = text.lstrip('\n')
         output = output.strip('\n')
-        request = MinimalRequest()
+        request = MinimalRequest(self.request)
+        page = MinimalPage()
         formatter = MoinMoin.formatter.text_gedit.Formatter(request)
-        formatter.setPage(MinimalPage())
+        formatter.setPage(page)
         MoinMoin.parser.wiki.Parser(text, request).format(formatter)
         repeat = ''.join(request.result).strip('\n')
         self.failUnlessEqual(repeat, output)
-        out = self.do_convert_real([request, repeat])
+        out = self.do_convert_real([request, page.page_name, repeat])
         self.failUnlessEqual(text, out)
 
     def testComment01(self):
@@ -899,13 +916,14 @@
         text = text.lstrip('\n')
         output = output.strip('\n')
         output = "<p>%s </p>" % output
-        request = MinimalRequest()
+        request = MinimalRequest(self.request)
+        page = MinimalPage()
         formatter = MoinMoin.formatter.text_gedit.Formatter(request)
-        formatter.setPage(MinimalPage())
+        formatter.setPage(page)
         MoinMoin.parser.wiki.Parser(text, request).format(formatter)
         repeat = ''.join(request.result).strip('\n')
         self.failUnlessEqual(repeat, output)
-        out = self.do_convert_real([request, repeat])
+        out = self.do_convert_real([request, page.page_name, repeat])
         out = out.rstrip('\n')
         self.failUnlessEqual(text, out)
 
@@ -1009,13 +1027,14 @@
         text = text.lstrip('\n')
         output = output.strip('\n')
         output = "<p>%s </p>" % output
-        request = MinimalRequest()
+        request = MinimalRequest(self.request)
+        page = MinimalPage()
         formatter = MoinMoin.formatter.text_gedit.Formatter(request)
-        formatter.setPage(MinimalPage())
+        formatter.setPage(page)
         MoinMoin.parser.wiki.Parser(text, request).format(formatter)
         repeat = ''.join(request.result).strip('\n')
         self.failUnlessEqual(repeat, output)
-        out = self.do_convert_real([request, repeat])
+        out = self.do_convert_real([request, page.page_name, repeat])
         out = out.rstrip('\n')
         self.failUnlessEqual(text, out)
 
@@ -1089,8 +1108,9 @@
     def do(self, text, output):
         text = text.strip('\n')
         output = output.lstrip('\n')
-        request = MinimalRequest()
-        out = self.do_convert_real([request, text])
+        request = MinimalRequest(self.request)
+        page = MinimalPage()
+        out = self.do_convert_real([request, page.page_name, text])
         self.failUnlessEqual(output, out)
 
     def testList01(self):