annotate MoinMoin/macro/_tests/test_FootNote.py @ 3244:886b8969dbc6

fix some unit tests
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Wed, 12 Mar 2008 01:08:43 +0100
parents b7914fb12243
children 7ee94ad36708
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3056
b7914fb12243 macro.FootNote: bug fix for MoinMoinBugs/FootNoteNumbering (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
b7914fb12243 macro.FootNote: bug fix for MoinMoinBugs/FootNoteNumbering (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
2 """
b7914fb12243 macro.FootNote: bug fix for MoinMoinBugs/FootNoteNumbering (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
3 MoinMoin - MoinMoin.macro.FootNote Tests
b7914fb12243 macro.FootNote: bug fix for MoinMoinBugs/FootNoteNumbering (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
4
b7914fb12243 macro.FootNote: bug fix for MoinMoinBugs/FootNoteNumbering (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
5 @copyright: 2008 MoinMoin:ReimarBauer
b7914fb12243 macro.FootNote: bug fix for MoinMoinBugs/FootNoteNumbering (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
6
b7914fb12243 macro.FootNote: bug fix for MoinMoinBugs/FootNoteNumbering (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
7 @license: GNU GPL, see COPYING for details.
b7914fb12243 macro.FootNote: bug fix for MoinMoinBugs/FootNoteNumbering (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
8 """
b7914fb12243 macro.FootNote: bug fix for MoinMoinBugs/FootNoteNumbering (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
9 import os
b7914fb12243 macro.FootNote: bug fix for MoinMoinBugs/FootNoteNumbering (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
10 from MoinMoin import macro
b7914fb12243 macro.FootNote: bug fix for MoinMoinBugs/FootNoteNumbering (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
11 from MoinMoin.macro import FootNote
b7914fb12243 macro.FootNote: bug fix for MoinMoinBugs/FootNoteNumbering (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
12 from MoinMoin.Page import Page
b7914fb12243 macro.FootNote: bug fix for MoinMoinBugs/FootNoteNumbering (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
13 from MoinMoin.PageEditor import PageEditor
b7914fb12243 macro.FootNote: bug fix for MoinMoinBugs/FootNoteNumbering (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
14
b7914fb12243 macro.FootNote: bug fix for MoinMoinBugs/FootNoteNumbering (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
15
b7914fb12243 macro.FootNote: bug fix for MoinMoinBugs/FootNoteNumbering (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
16 class TestFootNote:
b7914fb12243 macro.FootNote: bug fix for MoinMoinBugs/FootNoteNumbering (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
17 """ testing macro Action calling action raw """
b7914fb12243 macro.FootNote: bug fix for MoinMoinBugs/FootNoteNumbering (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
18
b7914fb12243 macro.FootNote: bug fix for MoinMoinBugs/FootNoteNumbering (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
19 def setup_class(self):
b7914fb12243 macro.FootNote: bug fix for MoinMoinBugs/FootNoteNumbering (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
20 self.pagename = u'AutoCreatedMoinMoinTemporaryTestPageForFootNote'
b7914fb12243 macro.FootNote: bug fix for MoinMoinBugs/FootNoteNumbering (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
21 self.page = PageEditor(self.request, self.pagename)
b7914fb12243 macro.FootNote: bug fix for MoinMoinBugs/FootNoteNumbering (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
22 self.shouldDeleteTestPage = True
b7914fb12243 macro.FootNote: bug fix for MoinMoinBugs/FootNoteNumbering (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
23
b7914fb12243 macro.FootNote: bug fix for MoinMoinBugs/FootNoteNumbering (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
24 def teardown_class(self):
b7914fb12243 macro.FootNote: bug fix for MoinMoinBugs/FootNoteNumbering (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
25 if self.shouldDeleteTestPage:
b7914fb12243 macro.FootNote: bug fix for MoinMoinBugs/FootNoteNumbering (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
26 import shutil
b7914fb12243 macro.FootNote: bug fix for MoinMoinBugs/FootNoteNumbering (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
27 page = Page(self.request, self.pagename)
b7914fb12243 macro.FootNote: bug fix for MoinMoinBugs/FootNoteNumbering (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
28 fpath = page.getPagePath(use_underlay=0, check_create=0)
b7914fb12243 macro.FootNote: bug fix for MoinMoinBugs/FootNoteNumbering (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
29 shutil.rmtree(fpath, True)
b7914fb12243 macro.FootNote: bug fix for MoinMoinBugs/FootNoteNumbering (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
30
b7914fb12243 macro.FootNote: bug fix for MoinMoinBugs/FootNoteNumbering (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
31 fpath = self.request.rootpage.getPagePath('event-log', isfile=1)
b7914fb12243 macro.FootNote: bug fix for MoinMoinBugs/FootNoteNumbering (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
32 if os.path.exists(fpath):
b7914fb12243 macro.FootNote: bug fix for MoinMoinBugs/FootNoteNumbering (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
33 os.remove(fpath)
b7914fb12243 macro.FootNote: bug fix for MoinMoinBugs/FootNoteNumbering (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
34
b7914fb12243 macro.FootNote: bug fix for MoinMoinBugs/FootNoteNumbering (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
35 def _make_macro(self):
b7914fb12243 macro.FootNote: bug fix for MoinMoinBugs/FootNoteNumbering (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
36 """Test helper"""
b7914fb12243 macro.FootNote: bug fix for MoinMoinBugs/FootNoteNumbering (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
37 from MoinMoin.parser.text import Parser
b7914fb12243 macro.FootNote: bug fix for MoinMoinBugs/FootNoteNumbering (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
38 from MoinMoin.formatter.text_html import Formatter
b7914fb12243 macro.FootNote: bug fix for MoinMoinBugs/FootNoteNumbering (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
39 p = Parser("##\n", self.request)
b7914fb12243 macro.FootNote: bug fix for MoinMoinBugs/FootNoteNumbering (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
40 p.formatter = Formatter(self.request)
b7914fb12243 macro.FootNote: bug fix for MoinMoinBugs/FootNoteNumbering (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
41 p.formatter.page = self.page
b7914fb12243 macro.FootNote: bug fix for MoinMoinBugs/FootNoteNumbering (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
42 self.request.formatter = p.formatter
b7914fb12243 macro.FootNote: bug fix for MoinMoinBugs/FootNoteNumbering (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
43 p.form = self.request.form
b7914fb12243 macro.FootNote: bug fix for MoinMoinBugs/FootNoteNumbering (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
44 m = macro.Macro(p)
b7914fb12243 macro.FootNote: bug fix for MoinMoinBugs/FootNoteNumbering (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
45 return m
b7914fb12243 macro.FootNote: bug fix for MoinMoinBugs/FootNoteNumbering (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
46
b7914fb12243 macro.FootNote: bug fix for MoinMoinBugs/FootNoteNumbering (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
47 def test_enumbering(self):
b7914fb12243 macro.FootNote: bug fix for MoinMoinBugs/FootNoteNumbering (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
48 """ module_tested: enumbering of Footnotes"""
b7914fb12243 macro.FootNote: bug fix for MoinMoinBugs/FootNoteNumbering (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
49 m = self._make_macro()
b7914fb12243 macro.FootNote: bug fix for MoinMoinBugs/FootNoteNumbering (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
50 text = 'a'
3244
886b8969dbc6 fix some unit tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3056
diff changeset
51 FootNote.macro_FootNote(m, text)
3056
b7914fb12243 macro.FootNote: bug fix for MoinMoinBugs/FootNoteNumbering (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
52 text = 'b'
3244
886b8969dbc6 fix some unit tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3056
diff changeset
53 FootNote.macro_FootNote(m, text)
3056
b7914fb12243 macro.FootNote: bug fix for MoinMoinBugs/FootNoteNumbering (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
54 result = FootNote.emit_footnotes(m.request, m.request.formatter)
b7914fb12243 macro.FootNote: bug fix for MoinMoinBugs/FootNoteNumbering (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
55
b7914fb12243 macro.FootNote: bug fix for MoinMoinBugs/FootNoteNumbering (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
56 assert result.endswith('2</a>)</li></ol></div>')
b7914fb12243 macro.FootNote: bug fix for MoinMoinBugs/FootNoteNumbering (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
57
b7914fb12243 macro.FootNote: bug fix for MoinMoinBugs/FootNoteNumbering (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
58
b7914fb12243 macro.FootNote: bug fix for MoinMoinBugs/FootNoteNumbering (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
59 coverage_modules = ['MoinMoin.macro.FootNote']
b7914fb12243 macro.FootNote: bug fix for MoinMoinBugs/FootNoteNumbering (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
60