changeset 2175:7a3f7ac4f6e0

fix formatter setup for tests, skip broken dom_xml formatter test, add small/big to text_xml formatter (ported from 1.6)
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Wed, 20 Jun 2007 14:56:00 +0200
parents f5f4dbbd0c51
children 7917222e0e05
files MoinMoin/_tests/test_formatter.py MoinMoin/conftest.py MoinMoin/formatter/text_xml.py
diffstat 3 files changed, 41 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/_tests/test_formatter.py	Wed Jun 20 14:37:58 2007 +0200
+++ b/MoinMoin/_tests/test_formatter.py	Wed Jun 20 14:56:00 2007 +0200
@@ -6,7 +6,9 @@
     @license: GNU GPL, see COPYING for details.
 """
 
+import py
 from unittest import TestCase
+
 import re
 
 from MoinMoin.Page import Page
@@ -14,15 +16,42 @@
 
 
 class TestFormatter(TestCase):
-    def testSyntaxReference(self):
-        formatters = wikiutil.getPlugins("formatter", self.request.cfg)
+    def testSyntaxReferenceDomXml(self):
+        py.test.skip("dom_xml formatter is known broken")
+        f_name = 'dom_xml'
+        try:
+            formatter = wikiutil.importPlugin(self.request.cfg, "formatter", f_name, "Formatter")
+        except wikiutil.PluginAttributeError:
+            pass
+        else:
+            print "Formatting using %r" % formatter
+            self.formatPage("SyntaxReference", formatter)
+            print "Done."
 
+    def testSyntaxReferenceDocBook(self):
         try:
             from xml.dom import getDOMImplementation
             dom = getDOMImplementation("4DOM")
         except ImportError:
             # if we don't have 4suite installed, the docbook formatter would just raise an exception
-            formatters.remove('text_docbook')
+            py.test.skip("not testing docbook formatter because no 4suite installed")
+        else:
+            f_name = 'text_docbook'
+            try:
+                formatter = wikiutil.importPlugin(self.request.cfg, "formatter", f_name, "Formatter")
+            except wikiutil.PluginAttributeError:
+                pass
+            else:
+                print "Formatting using %r" % formatter
+                self.formatPage("SyntaxReference", formatter)
+                print "Done."
+
+    def testSyntaxReferenceOthers(self):
+        formatters = wikiutil.getPlugins("formatter", self.request.cfg)
+
+        # we have separate tests for those:
+        formatters.remove('text_docbook')
+        formatters.remove('dom_xml')
 
         for f_name in formatters:
             try:
--- a/MoinMoin/conftest.py	Wed Jun 20 14:37:58 2007 +0200
+++ b/MoinMoin/conftest.py	Wed Jun 20 14:56:00 2007 +0200
@@ -74,12 +74,15 @@
 def init_test_request(static_state=[False]):
     from MoinMoin.request import CLI
     from MoinMoin.user import User
+    from MoinMoin.formatter.text_html import Formatter as HtmlFormatter
     if not static_state[0]:
         maketestwiki.run(True)
         static_state[0] = True
     request = CLI.Request()
     request.form = request.args = request.setup_args()
     request.user = User(request)
+    request.html_formatter = HtmlFormatter(request)
+    request.formatter = request.html_formatter
     return request
 
 
--- a/MoinMoin/formatter/text_xml.py	Wed Jun 20 14:37:58 2007 +0200
+++ b/MoinMoin/formatter/text_xml.py	Wed Jun 20 14:56:00 2007 +0200
@@ -118,6 +118,12 @@
     def code(self, on, **kw):
         return ['<code>', '</code>'][not on]
 
+    def small(self, on, **kw):
+        return ['<small>', '</small>'][not on]
+
+    def big(self, on, **kw):
+        return ['<big>', '</big>'][not on]
+
     def sup(self, on, **kw):
         return ['<sup>', '</sup>'][not on]