changeset 3056:b7914fb12243

macro.FootNote: bug fix for MoinMoinBugs/FootNoteNumbering (ported from 1.6)
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Thu, 21 Feb 2008 19:41:15 +0100
parents 29d236eb2ab7
children 9c58f31af69e
files MoinMoin/macro/FootNote.py MoinMoin/macro/_tests/test_FootNote.py
diffstat 2 files changed, 62 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/macro/FootNote.py	Wed Feb 20 11:07:18 2008 +0100
+++ b/MoinMoin/macro/FootNote.py	Thu Feb 21 19:41:15 2008 +0100
@@ -70,7 +70,7 @@
 
         # Add footnotes list
         result.append(formatter.number_list(1))
-
+        subidx = 0
         for ctr in range(request.footnote_ctr):
             fn_txt = request.footnotes[ctr]
             if not fn_txt in request.footnotes:
@@ -86,7 +86,7 @@
             result.append(wikiutil.renderText(request, WikiParser, fn_txt))
 
             items = []
-            subidx = 0
+            # ToDo check why that loop is needed?
             for backlink_id, idx in this_txt_footnotes:
                 # Add item
                 item = formatter.anchorlink(1, backlink_id)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MoinMoin/macro/_tests/test_FootNote.py	Thu Feb 21 19:41:15 2008 +0100
@@ -0,0 +1,60 @@
+# -*- coding: utf-8 -*-
+"""
+    MoinMoin - MoinMoin.macro.FootNote Tests
+
+    @copyright: 2008 MoinMoin:ReimarBauer
+
+    @license: GNU GPL, see COPYING for details.
+"""
+import os
+from MoinMoin import macro
+from MoinMoin.macro import FootNote
+from MoinMoin.Page import Page
+from MoinMoin.PageEditor import PageEditor
+
+
+class TestFootNote:
+    """ testing macro Action calling action raw """
+
+    def setup_class(self):
+        self.pagename = u'AutoCreatedMoinMoinTemporaryTestPageForFootNote'
+        self.page = PageEditor(self.request, self.pagename)
+        self.shouldDeleteTestPage = True
+
+    def teardown_class(self):
+        if self.shouldDeleteTestPage:
+            import shutil
+            page = Page(self.request, self.pagename)
+            fpath = page.getPagePath(use_underlay=0, check_create=0)
+            shutil.rmtree(fpath, True)
+
+            fpath = self.request.rootpage.getPagePath('event-log', isfile=1)
+            if os.path.exists(fpath):
+                os.remove(fpath)
+
+    def _make_macro(self):
+        """Test helper"""
+        from MoinMoin.parser.text import Parser
+        from MoinMoin.formatter.text_html import Formatter
+        p = Parser("##\n", self.request)
+        p.formatter = Formatter(self.request)
+        p.formatter.page = self.page
+        self.request.formatter = p.formatter
+        p.form = self.request.form
+        m = macro.Macro(p)
+        return m
+
+    def test_enumbering(self):
+        """ module_tested: enumbering of Footnotes"""
+        m = self._make_macro()
+        text = 'a'
+        FootNote.execute(m, text)
+        text = 'b'
+        FootNote.execute(m, text)
+        result = FootNote.emit_footnotes(m.request, m.request.formatter)
+
+        assert result.endswith('2</a>)</li></ol></div>')
+
+
+coverage_modules = ['MoinMoin.macro.FootNote']
+