annotate MoinMoin/parser/_tests/test_text_moin_wiki.py @ 3143:16ae95df840a

i18n.getText: fixed some callers that had still 'formatted=' kw args
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Wed, 27 Feb 2008 15:52:30 +0100
parents 1d3e65884337
children b06c048233f2
rev   line source
2256
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
1 # -*- coding: iso-8859-1 -*-
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
2 """
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
3 MoinMoin - MoinMoin.parser.text_moin_wiki Tests
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
4
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
5 TODO: these are actually parser+formatter tests. We should have
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
6 parser only tests here.
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
7
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
8 @copyright: 2003-2004 by Juergen Hermann <jh@web.de>
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
9 @license: GNU GPL, see COPYING for details.
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
10 """
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
11
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
12 import re
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
13 from StringIO import StringIO
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
14
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
15 import py
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
16
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
17 from MoinMoin.Page import Page
2621
6bb7cad1a039 tests: simplify parser test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2572
diff changeset
18 from MoinMoin.parser.text_moin_wiki import Parser as WikiParser
6bb7cad1a039 tests: simplify parser test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2572
diff changeset
19 from MoinMoin.formatter.text_html import Formatter as HtmlFormatter
2256
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
20
2778
c8dd346f146e parser: anchor, bang_meta, relative pagelink fixes, more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2775
diff changeset
21 PAGENAME = u'ThisPageDoesNotExistsAndWillNeverBeReally'
2256
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
22
2624
3d30e923448f wiki parser tests: convert to py.test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2623
diff changeset
23 class ParserTestCase(object):
2256
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
24 """ Helper class that provide a parsing method """
2261
7e04a576e8c7 test_text_moin_wiki: small PEP8 changes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2258
diff changeset
25
2256
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
26 def parse(self, body):
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
27 """Parse body and return html
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
28
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
29 Create a page with body, then parse it and format using html formatter
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
30 """
2621
6bb7cad1a039 tests: simplify parser test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2572
diff changeset
31 request = self.request
2256
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
32 assert body is not None
2621
6bb7cad1a039 tests: simplify parser test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2572
diff changeset
33 request.reset()
2778
c8dd346f146e parser: anchor, bang_meta, relative pagelink fixes, more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2775
diff changeset
34 page = Page(request, PAGENAME)
2256
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
35 page.hilite_re = None
2621
6bb7cad1a039 tests: simplify parser test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2572
diff changeset
36 page.set_raw_body(body)
6bb7cad1a039 tests: simplify parser test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2572
diff changeset
37 formatter = HtmlFormatter(request)
6bb7cad1a039 tests: simplify parser test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2572
diff changeset
38 formatter.setPage(page)
6bb7cad1a039 tests: simplify parser test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2572
diff changeset
39 page.formatter = formatter
6bb7cad1a039 tests: simplify parser test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2572
diff changeset
40 request.formatter = formatter
2622
1b2078bafdaa wiki parser tests: fixed line_anchor problems and some other broken tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2621
diff changeset
41 parser = WikiParser(body, request, line_anchors=False)
2621
6bb7cad1a039 tests: simplify parser test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2572
diff changeset
42 formatter.startContent('') # needed for _include_stack init
6bb7cad1a039 tests: simplify parser test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2572
diff changeset
43 output = request.redirectedOutput(parser.format, formatter)
6bb7cad1a039 tests: simplify parser test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2572
diff changeset
44 formatter.endContent('')
6bb7cad1a039 tests: simplify parser test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2572
diff changeset
45 return output
2256
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
46
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
47
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
48 class TestParagraphs(ParserTestCase):
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
49 """ Test paragraphs creating
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
50
2622
1b2078bafdaa wiki parser tests: fixed line_anchor problems and some other broken tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2621
diff changeset
51 All tests ignoring white space in output.
1b2078bafdaa wiki parser tests: fixed line_anchor problems and some other broken tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2621
diff changeset
52 We do not test for </p> as it is not there currently.
2256
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
53 """
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
54
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
55 def testFirstParagraph(self):
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
56 """ parser.wiki: first paragraph should be in <p> """
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
57 result = self.parse('First')
2624
3d30e923448f wiki parser tests: convert to py.test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2623
diff changeset
58 assert re.search(r'<p.*?>\s*First\s*', result)
2256
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
59
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
60 def testEmptyLineBetweenParagraphs(self):
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
61 """ parser.wiki: empty line separates paragraphs """
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
62 result = self.parse('First\n\nSecond')
2624
3d30e923448f wiki parser tests: convert to py.test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2623
diff changeset
63 assert re.search(r'<p.*?>\s*Second\s*', result)
2261
7e04a576e8c7 test_text_moin_wiki: small PEP8 changes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2258
diff changeset
64
2256
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
65 def testParagraphAfterBlockMarkup(self):
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
66 """ parser.wiki: create paragraph after block markup """
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
67
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
68 markup = (
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
69 '----\n',
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
70 '|| table ||\n',
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
71 '= heading 1 =\n',
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
72 '== heading 2 ==\n',
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
73 '=== heading 3 ===\n',
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
74 '==== heading 4 ====\n',
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
75 '===== heading 5 =====\n',
2725
388204baf00f change [[macro]] to <<macro>> in all built-in markup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2624
diff changeset
76 # '<<en>>\n', XXX crashes
2256
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
77 )
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
78 for item in markup:
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
79 text = item + 'Paragraph'
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
80 result = self.parse(text)
2624
3d30e923448f wiki parser tests: convert to py.test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2623
diff changeset
81 assert re.search(r'<p.*?>\s*Paragraph\s*', result)
2256
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
82
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
83
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
84 class TestHeadings(ParserTestCase):
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
85 """ Test various heading problems """
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
86
2624
3d30e923448f wiki parser tests: convert to py.test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2623
diff changeset
87 def class_setup(self):
2256
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
88 """ Require show_section_numbers = 0 to workaround counter
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
89 global state saved in request.
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
90 """
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
91 self.config = self.TestConfig(show_section_numbers=0)
2261
7e04a576e8c7 test_text_moin_wiki: small PEP8 changes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2258
diff changeset
92
2624
3d30e923448f wiki parser tests: convert to py.test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2623
diff changeset
93 def class_teardown(self):
2256
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
94 del self.config
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
95
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
96 def testIgnoreWhiteSpaceAroundHeadingText(self):
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
97 """ parser.wiki: ignore white space around heading text
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
98
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
99 See bug: TableOfContentsBreakOnExtraSpaces.
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
100
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
101 Does not test mapping of '=' to h number, or valid html markup.
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
102 """
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
103 tests = (
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
104 '= head =\n', # leading
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
105 '= head =\n', # trailing
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
106 '= head =\n' # both
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
107 )
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
108 expected = self.parse('= head =')
2261
7e04a576e8c7 test_text_moin_wiki: small PEP8 changes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2258
diff changeset
109 for test in tests:
2256
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
110 result = self.parse(test)
2624
3d30e923448f wiki parser tests: convert to py.test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2623
diff changeset
111 assert result == expected
2256
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
112
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
113
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
114 class TestTOC(ParserTestCase):
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
115
2624
3d30e923448f wiki parser tests: convert to py.test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2623
diff changeset
116 def class_setup(self):
2256
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
117 """ Require show_section_numbers = 0 to workaround counter
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
118 global state saved in request.
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
119 """
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
120 self.config = self.TestConfig(show_section_numbers=0)
2261
7e04a576e8c7 test_text_moin_wiki: small PEP8 changes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2258
diff changeset
121
2624
3d30e923448f wiki parser tests: convert to py.test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2623
diff changeset
122 def class_teardown(self):
2256
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
123 del self.config
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
124
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
125 def testHeadingWithWhiteSpace(self):
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
126 """ parser.wiki: TOC links to headings with white space
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
127
2256
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
128 See bug: TableOfContentsBreakOnExtraSpaces.
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
129
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
130 Does not test TOC or heading formating, just verify that spaces
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
131 around heading text does not matter.
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
132 """
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
133 standard = """
2725
388204baf00f change [[macro]] to <<macro>> in all built-in markup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2624
diff changeset
134 <<TableOfContents>>
2256
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
135 = heading =
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
136 Text
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
137 """
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
138 withWhitespace = """
2725
388204baf00f change [[macro]] to <<macro>> in all built-in markup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2624
diff changeset
139 <<TableOfContents>>
2256
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
140 = heading =
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
141 Text
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
142 """
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
143 expected = self.parse(standard)
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
144 result = self.parse(withWhitespace)
2624
3d30e923448f wiki parser tests: convert to py.test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2623
diff changeset
145 assert result == expected
2261
7e04a576e8c7 test_text_moin_wiki: small PEP8 changes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2258
diff changeset
146
2256
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
147
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
148 class TestDateTimeMacro(ParserTestCase):
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
149 """ Test DateTime macro
2261
7e04a576e8c7 test_text_moin_wiki: small PEP8 changes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2258
diff changeset
150
2292
953a0e4e3dac tests: document some DateTime timezone related test failure we can't easily fix for some special cases
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2286
diff changeset
151 If you get failures in these tests, it might be because:
953a0e4e3dac tests: document some DateTime timezone related test failure we can't easily fix for some special cases
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2286
diff changeset
152 * libc problems (some are just broken/incorrect)
953a0e4e3dac tests: document some DateTime timezone related test failure we can't easily fix for some special cases
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2286
diff changeset
153 * changes in the timezone of a country (e.g. Lithuania seems
953a0e4e3dac tests: document some DateTime timezone related test failure we can't easily fix for some special cases
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2286
diff changeset
154 to have changed the tz it is in, see comments below). Our
953a0e4e3dac tests: document some DateTime timezone related test failure we can't easily fix for some special cases
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2286
diff changeset
155 timestamps are in UTC, but we use mktime(), which is the inverse
953a0e4e3dac tests: document some DateTime timezone related test failure we can't easily fix for some special cases
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2286
diff changeset
156 function of localtime() (NOT of gmtime()), so we have to fix
953a0e4e3dac tests: document some DateTime timezone related test failure we can't easily fix for some special cases
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2286
diff changeset
157 our calculation with the tzoffset. Problem: we can't easily find
953a0e4e3dac tests: document some DateTime timezone related test failure we can't easily fix for some special cases
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2286
diff changeset
158 out the tzoffset some location had at some time in the past.
953a0e4e3dac tests: document some DateTime timezone related test failure we can't easily fix for some special cases
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2286
diff changeset
159 Badly enough, we also don't have an inverse function of gmtime().
2256
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
160
2292
953a0e4e3dac tests: document some DateTime timezone related test failure we can't easily fix for some special cases
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2286
diff changeset
161 If some of these tests fail and show differences of e.g. 1 hour,
953a0e4e3dac tests: document some DateTime timezone related test failure we can't easily fix for some special cases
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2286
diff changeset
162 you might see your timestamps being off by 1 hour in the wiki.
953a0e4e3dac tests: document some DateTime timezone related test failure we can't easily fix for some special cases
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2286
diff changeset
163 If you can live with that, this will cause no other problems.
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
164 """
2261
7e04a576e8c7 test_text_moin_wiki: small PEP8 changes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2258
diff changeset
165
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
166 text = 'AAA %s AAA'
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
167 needle = re.compile(text % r'(.+)')
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
168 _tests = (
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
169 # test expected
2725
388204baf00f change [[macro]] to <<macro>> in all built-in markup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2624
diff changeset
170 (u'<<DateTime(259200)>>', '1970-01-04 00:00:00'),
388204baf00f change [[macro]] to <<macro>> in all built-in markup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2624
diff changeset
171 (u'<<DateTime(2003-03-03T03:03:03)>>', '2003-03-03 03:03:03'),
388204baf00f change [[macro]] to <<macro>> in all built-in markup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2624
diff changeset
172 (u'<<DateTime(2000-01-01T00:00:00Z)>>', '2000-01-01 00:00:00'), # works for Europe/Vilnius
388204baf00f change [[macro]] to <<macro>> in all built-in markup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2624
diff changeset
173 (u'<<Date(2002-02-02T01:02:03Z)>>', '2002-02-02'),
388204baf00f change [[macro]] to <<macro>> in all built-in markup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2624
diff changeset
174 (u'<<DateTime(1970-01-06T00:00:00)>>', '1970-01-06 00:00:00'), # fails e.g. for Europe/Vilnius
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
175 )
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
176
2624
3d30e923448f wiki parser tests: convert to py.test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2623
diff changeset
177 def class_setup(self):
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
178 """ Require default date and time format config values """
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
179 self.config = self.TestConfig(defaults=('date_fmt', 'datetime_fmt'))
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
180
2624
3d30e923448f wiki parser tests: convert to py.test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2623
diff changeset
181 def class_teardown(self):
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
182 del self.config
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
183
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
184 def testDateTimeMacro(self):
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
185 """ parser.wiki: DateTime macro """
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
186 note = """
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
187
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
188 If this fails, it is likely a problem in your python / libc,
2292
953a0e4e3dac tests: document some DateTime timezone related test failure we can't easily fix for some special cases
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2286
diff changeset
189 not in moin. See also: <http://sourceforge.net/tracker/index.php?func=detail&aid=902172&group_id=5470&atid=105470>
2362
2332678361bd Fix trailing whitespace.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2292
diff changeset
190
2292
953a0e4e3dac tests: document some DateTime timezone related test failure we can't easily fix for some special cases
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2286
diff changeset
191 It can also be related to TZ changes a country historically made.
953a0e4e3dac tests: document some DateTime timezone related test failure we can't easily fix for some special cases
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2286
diff changeset
192 """
2256
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
193
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
194 for test, expected in self._tests:
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
195 html = self.parse(self.text % test)
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
196 result = self.needle.search(html).group(1)
2624
3d30e923448f wiki parser tests: convert to py.test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2623
diff changeset
197 assert result == expected
2261
7e04a576e8c7 test_text_moin_wiki: small PEP8 changes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2258
diff changeset
198
2256
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
199
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
200 class TestTextFormatingTestCase(ParserTestCase):
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
201 """ Test wiki markup """
2261
7e04a576e8c7 test_text_moin_wiki: small PEP8 changes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2258
diff changeset
202
2256
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
203 text = 'AAA %s AAA'
2261
7e04a576e8c7 test_text_moin_wiki: small PEP8 changes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2258
diff changeset
204 needle = re.compile(text % r'(.+)')
2256
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
205 _tests = (
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
206 # test, expected
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
207 ('no format', 'no format'),
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
208 ("''em''", '<em>em</em>'),
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
209 ("'''bold'''", '<strong>bold</strong>'),
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
210 ("__underline__", '<span class="u">underline</span>'),
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
211 ("'''''Mix''' at start''", '<em><strong>Mix</strong> at start</em>'),
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
212 ("'''''Mix'' at start'''", '<strong><em>Mix</em> at start</strong>'),
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
213 ("'''Mix at ''end'''''", '<strong>Mix at <em>end</em></strong>'),
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
214 ("''Mix at '''end'''''", '<em>Mix at <strong>end</strong></em>'),
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
215 )
2261
7e04a576e8c7 test_text_moin_wiki: small PEP8 changes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2258
diff changeset
216
2256
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
217 def testTextFormating(self):
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
218 """ parser.wiki: text formating """
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
219 for test, expected in self._tests:
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
220 html = self.parse(self.text % test)
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
221 result = self.needle.search(html).group(1)
2624
3d30e923448f wiki parser tests: convert to py.test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2623
diff changeset
222 assert result == expected
2256
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
223
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
224
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
225 class TestCloseInlineTestCase(ParserTestCase):
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
226
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
227 def testCloseOneInline(self):
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
228 """ parser.wiki: close open inline tag when block close """
2622
1b2078bafdaa wiki parser tests: fixed line_anchor problems and some other broken tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2621
diff changeset
229 py.test.skip("Broken")
2256
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
230 cases = (
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
231 # test, expected
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
232 ("text'''text\n", r"<p>text<strong>text\s*</strong></p>"),
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
233 ("text''text\n", r"<p>text<em>text\s*</em></p>"),
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
234 ("text__text\n", r"<p>text<span class=\"u\">text\s*</span></p>"),
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
235 ("text ''em '''em strong __em strong underline",
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
236 r"text <em>em <strong>em strong <span class=\"u\">em strong underline"
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
237 r"\s*</span></strong></em></p>"),
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
238 )
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
239 for test, expected in cases:
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
240 result = self.parse(test)
2624
3d30e923448f wiki parser tests: convert to py.test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2623
diff changeset
241 assert re.search(expected, result)
2256
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
242
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
243
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
244 class TestInlineCrossing(ParserTestCase):
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
245 """
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
246 This test case fail with current parser/formatter and should be fixed in 2.0
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
247 """
2261
7e04a576e8c7 test_text_moin_wiki: small PEP8 changes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2258
diff changeset
248
2256
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
249 def disabled_testInlineCrossing(self):
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
250 """ parser.wiki: prevent inline crossing <a><b></a></b> """
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
251
2269
9f9a79d5a8d9 tests: move macro and parser tests to macro/_tests and parser/_tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2263
diff changeset
252 expected = (r"<p><em>a<strong>ab</strong></em><strong>b</strong>\s*</p>")
2256
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
253 test = "''a'''ab''b'''\n"
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
254 result = self.parse(test)
2624
3d30e923448f wiki parser tests: convert to py.test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2623
diff changeset
255 assert re.search(expected, result)
2261
7e04a576e8c7 test_text_moin_wiki: small PEP8 changes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2258
diff changeset
256
2256
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
257
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
258 class TestEscapeHTML(ParserTestCase):
2261
7e04a576e8c7 test_text_moin_wiki: small PEP8 changes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2258
diff changeset
259
2256
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
260 def testEscapeInTT(self):
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
261 """ parser.wiki: escape html markup in `tt` """
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
262 test = 'text `<escape-me>` text\n'
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
263 self._test(test)
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
264
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
265 def testEscapeInTT2(self):
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
266 """ parser.wiki: escape html markup in {{{tt}}} """
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
267 test = 'text {{{<escape-me>}}} text\n'
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
268 self._test(test)
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
269
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
270 def testEscapeInPre(self):
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
271 """ parser.wiki: escape html markup in pre """
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
272 test = '''{{{
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
273 <escape-me>
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
274 }}}
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
275 '''
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
276 self._test(test)
2261
7e04a576e8c7 test_text_moin_wiki: small PEP8 changes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2258
diff changeset
277
2256
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
278 def testEscapeInPreHashbang(self):
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
279 """ parser.wiki: escape html markup in pre with hashbang """
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
280 test = '''{{{#!
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
281 <escape-me>
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
282 }}}
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
283 '''
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
284 self._test(test)
2261
7e04a576e8c7 test_text_moin_wiki: small PEP8 changes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2258
diff changeset
285
2256
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
286 def testEscapeInPythonCodeArea(self):
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
287 """ parser.wiki: escape html markup in python code area """
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
288 test = '''{{{#!python
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
289 #<escape-me>
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
290 }}}
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
291 '''
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
292 self._test(test)
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
293
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
294 def testEscapeInGetTextMacro(self):
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
295 """ parser.wiki: escape html markup in GetText macro """
2725
388204baf00f change [[macro]] to <<macro>> in all built-in markup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2624
diff changeset
296 test = "text <<GetText(<escape-me>)>> text"
2256
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
297 self._test(test)
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
298
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
299 def testEscapeInGetTextFormatted(self):
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
300 """ parser.wiki: escape html markup in getText formatted call """
3143
16ae95df840a i18n.getText: fixed some callers that had still 'formatted=' kw args
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3052
diff changeset
301 test = self.request.getText('<escape-me>', wiki=True)
2256
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
302 self._test(test)
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
303
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
304 def testEscapeInGetTextFormatedLink(self):
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
305 """ parser.wiki: escape html markup in getText formatted call with link """
3143
16ae95df840a i18n.getText: fixed some callers that had still 'formatted=' kw args
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3052
diff changeset
306 test = self.request.getText('[[<escape-me>]]', wiki=True)
2256
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
307 self._test(test)
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
308
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
309 def testEscapeInGetTextUnFormatted(self):
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
310 """ parser.wiki: escape html markup in getText non formatted call """
3143
16ae95df840a i18n.getText: fixed some callers that had still 'formatted=' kw args
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3052
diff changeset
311 test = self.request.getText('<escape-me>', wiki=False)
2256
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
312 self._test(test)
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
313
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
314 def _test(self, test):
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
315 expected = r'&lt;escape-me&gt;'
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
316 result = self.parse(test)
2624
3d30e923448f wiki parser tests: convert to py.test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2623
diff changeset
317 assert re.search(expected, result)
2256
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
318
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
319
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
320 class TestEscapeWikiTableMarkup(ParserTestCase):
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
321
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
322 def testEscapeInTT(self):
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
323 """ parser.wiki: escape wiki table markup in `tt` """
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
324 test = 'text `||<tablewidth="80"> Table ||` text\n'
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
325 self.do(test)
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
326
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
327 def testEscapeInTT2(self):
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
328 """ parser.wiki: escape wiki table markup in {{{tt}}} """
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
329 test = 'text {{{||<tablewidth="80"> Table ||}}} text\n'
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
330 self.do(test)
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
331
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
332 def testEscapeInPre(self):
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
333 """ parser.wiki: escape wiki table markup in pre """
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
334 test = '''{{{
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
335 ||<tablewidth="80"> Table ||
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
336 }}}
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
337 '''
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
338 self.do(test)
2261
7e04a576e8c7 test_text_moin_wiki: small PEP8 changes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2258
diff changeset
339
2256
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
340 def testEscapeInPreHashbang(self):
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
341 """ parser.wiki: escape wiki table markup in pre with hashbang """
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
342 test = '''{{{#!
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
343 ||<tablewidth="80"> Table ||
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
344 }}}
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
345 '''
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
346 self.do(test)
2261
7e04a576e8c7 test_text_moin_wiki: small PEP8 changes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2258
diff changeset
347
2256
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
348 def testEscapeInPythonCodeArea(self):
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
349 """ parser.wiki: escape wiki table markup in python code area """
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
350 test = '''{{{#!python
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
351 # ||<tablewidth="80"> Table ||
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
352 }}}
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
353 '''
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
354 self.do(test)
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
355
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
356 def do(self, test):
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
357 expected = r'&lt;tablewidth="80"&gt;'
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
358 result = self.parse(test)
2624
3d30e923448f wiki parser tests: convert to py.test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2623
diff changeset
359 assert re.search(expected, result)
2256
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
360
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
361
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
362 class TestRule(ParserTestCase):
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
363 """ Test rules markup """
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
364
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
365 def testNotRule(self):
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
366 """ parser.wiki: --- is no rule """
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
367 result = self.parse('---')
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
368 expected = '---' # inside <p>
2624
3d30e923448f wiki parser tests: convert to py.test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2623
diff changeset
369 assert expected in result
2256
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
370
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
371 def testStandardRule(self):
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
372 """ parser.wiki: ---- is standard rule """
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
373 result = self.parse('----')
2624
3d30e923448f wiki parser tests: convert to py.test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2623
diff changeset
374 assert re.search(r'<hr.*?>', result)
2256
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
375
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
376 def testVariableRule(self):
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
377 """ parser.wiki: ----- rules with size """
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
378
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
379 for size in range(5, 11):
2261
7e04a576e8c7 test_text_moin_wiki: small PEP8 changes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2258
diff changeset
380 test = '-' * size
2256
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
381 result = self.parse(test)
2624
3d30e923448f wiki parser tests: convert to py.test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2623
diff changeset
382 assert re.search(r'<hr class="hr%d".*?>' % (size - 4), result)
2256
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
383
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
384 def testLongRule(self):
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
385 """ parser.wiki: ------------ long rule shortened to hr6 """
2261
7e04a576e8c7 test_text_moin_wiki: small PEP8 changes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2258
diff changeset
386 test = '-' * 254
2256
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
387 result = self.parse(test)
2624
3d30e923448f wiki parser tests: convert to py.test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2623
diff changeset
388 assert re.search(r'<hr class="hr6".*?>', result)
2256
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
389
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
390
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
391 class TestBlock(ParserTestCase):
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
392 cases = (
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
393 # test, block start
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
394 ('----\n', '<hr'),
2622
1b2078bafdaa wiki parser tests: fixed line_anchor problems and some other broken tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2621
diff changeset
395 ('= Heading =\n', '<h1'),
2256
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
396 ('{{{\nPre\n}}}\n', '<pre'),
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
397 ('{{{\n#!python\nPre\n}}}\n', '<div'),
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
398 ('|| Table ||', '<div'),
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
399 (' * unordered list\n', '<ul'),
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
400 (' 1. ordered list\n', '<ol'),
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
401 (' indented text\n', '<ul'),
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
402 )
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
403
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
404 def testParagraphBeforeBlock(self):
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
405 """ parser.wiki: paragraph closed before block element """
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
406 text = """AAA
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
407 %s
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
408 """
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
409 for test, blockstart in self.cases:
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
410 # We dont test here formatter white space generation
2622
1b2078bafdaa wiki parser tests: fixed line_anchor problems and some other broken tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2621
diff changeset
411 expected = r'<p.*?>AAA\s*\n*%s' % blockstart
2256
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
412 needle = re.compile(expected, re.MULTILINE)
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
413 result = self.parse(text % test)
3052
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2778
diff changeset
414 print expected, result
2624
3d30e923448f wiki parser tests: convert to py.test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2623
diff changeset
415 assert needle.search(result)
2261
7e04a576e8c7 test_text_moin_wiki: small PEP8 changes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2258
diff changeset
416
2256
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
417 def testEmptyLineBeforeBlock(self):
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
418 """ parser.wiki: empty lines before block element ignored
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
419
2256
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
420 Empty lines separate paragraphs, but should be ignored if a block
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
421 element follow.
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
422
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
423 Currently an empty paragraph is created, which make no sense but
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
424 no real harm.
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
425 """
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
426 text = """AAA
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
427
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
428 %s
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
429 """
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
430 for test, blockstart in self.cases:
2622
1b2078bafdaa wiki parser tests: fixed line_anchor problems and some other broken tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2621
diff changeset
431 expected = r'<p.*?>AAA.*?(<p.*?>\s*)*%s' % blockstart # XXX ignores addtl. <p>
2256
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
432 needle = re.compile(expected, re.MULTILINE)
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
433 result = self.parse(text % test)
3052
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2778
diff changeset
434 print expected, result
2624
3d30e923448f wiki parser tests: convert to py.test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2623
diff changeset
435 assert needle.search(result)
2256
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
436
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
437 def testUrlAfterBlock(self):
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
438 """ parser.wiki: tests url after block element """
2572
ce0787373150 introduce ID cache in request, make everybody generate valid IDs even inside includes
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2535
diff changeset
439 case = 'some text {{{some block text\n}}} and a URL http://moinmo.in/'
2256
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
440
2572
ce0787373150 introduce ID cache in request, make everybody generate valid IDs even inside includes
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2535
diff changeset
441 result = self.parse(case)
ce0787373150 introduce ID cache in request, make everybody generate valid IDs even inside includes
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2535
diff changeset
442 assert result.find('and a URL <a ') > -1
ce0787373150 introduce ID cache in request, make everybody generate valid IDs even inside includes
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2535
diff changeset
443
ce0787373150 introduce ID cache in request, make everybody generate valid IDs even inside includes
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2535
diff changeset
444 def testWikiNameAfterBlock(self):
ce0787373150 introduce ID cache in request, make everybody generate valid IDs even inside includes
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2535
diff changeset
445 """ parser.wiki: tests url after block element """
ce0787373150 introduce ID cache in request, make everybody generate valid IDs even inside includes
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2535
diff changeset
446 case = 'some text {{{some block text\n}}} and a WikiName'
ce0787373150 introduce ID cache in request, make everybody generate valid IDs even inside includes
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2535
diff changeset
447
ce0787373150 introduce ID cache in request, make everybody generate valid IDs even inside includes
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2535
diff changeset
448 result = self.parse(case)
ce0787373150 introduce ID cache in request, make everybody generate valid IDs even inside includes
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2535
diff changeset
449 assert result.find('and a <a ') > -1
2256
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
450
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
451 def testColorizedPythonParserAndNestingPreBrackets(self):
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
452 """ tests nested {{{ }}} for the python colorized parser
2256
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
453 """
3052
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2778
diff changeset
454 raw = """{{{{
2258
9c66c14f6b62 text_moin_wiki: completing nesting for colorized parsers and some tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2256
diff changeset
455 #!python
9c66c14f6b62 text_moin_wiki: completing nesting for colorized parsers and some tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2256
diff changeset
456 import re
9c66c14f6b62 text_moin_wiki: completing nesting for colorized parsers and some tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2256
diff changeset
457 pattern = re.compile(r'{{{This is some nested text}}}')
3052
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2778
diff changeset
458 }}}}"""
2258
9c66c14f6b62 text_moin_wiki: completing nesting for colorized parsers and some tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2256
diff changeset
459 output = self.parse(raw)
9c66c14f6b62 text_moin_wiki: completing nesting for colorized parsers and some tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2256
diff changeset
460 output = ''.join(output)
2572
ce0787373150 introduce ID cache in request, make everybody generate valid IDs even inside includes
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2535
diff changeset
461 assert "r'{{{This is some nested text}}}'" in output
2258
9c66c14f6b62 text_moin_wiki: completing nesting for colorized parsers and some tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2256
diff changeset
462
9c66c14f6b62 text_moin_wiki: completing nesting for colorized parsers and some tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2256
diff changeset
463 def testNestingPreBrackets(self):
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
464 """ tests nested {{{ }}} for the wiki parser
2258
9c66c14f6b62 text_moin_wiki: completing nesting for colorized parsers and some tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2256
diff changeset
465 """
3052
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2778
diff changeset
466 raw = """{{{{
2258
9c66c14f6b62 text_moin_wiki: completing nesting for colorized parsers and some tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2256
diff changeset
467 Example
9c66c14f6b62 text_moin_wiki: completing nesting for colorized parsers and some tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2256
diff changeset
468 You can use {{{brackets}}}
3052
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2778
diff changeset
469 }}}}"""
2258
9c66c14f6b62 text_moin_wiki: completing nesting for colorized parsers and some tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2256
diff changeset
470 output = self.parse(raw)
9c66c14f6b62 text_moin_wiki: completing nesting for colorized parsers and some tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2256
diff changeset
471 output = ''.join(output)
9c66c14f6b62 text_moin_wiki: completing nesting for colorized parsers and some tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2256
diff changeset
472 print output
2572
ce0787373150 introduce ID cache in request, make everybody generate valid IDs even inside includes
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2535
diff changeset
473 assert 'You can use {{{brackets}}}' in output
2258
9c66c14f6b62 text_moin_wiki: completing nesting for colorized parsers and some tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2256
diff changeset
474
9c66c14f6b62 text_moin_wiki: completing nesting for colorized parsers and some tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2256
diff changeset
475 def testTextBeforeNestingPreBrackets(self):
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
476 """ tests text before nested {{{ }}} for the wiki parser
2258
9c66c14f6b62 text_moin_wiki: completing nesting for colorized parsers and some tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2256
diff changeset
477 """
9c66c14f6b62 text_moin_wiki: completing nesting for colorized parsers and some tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2256
diff changeset
478 raw = """Example
3052
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2778
diff changeset
479 {{{{
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2778
diff changeset
480 You can use {{{brackets}}}
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2778
diff changeset
481 }}}}"""
2258
9c66c14f6b62 text_moin_wiki: completing nesting for colorized parsers and some tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2256
diff changeset
482 output = self.parse(raw)
9c66c14f6b62 text_moin_wiki: completing nesting for colorized parsers and some tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2256
diff changeset
483 output = ''.join(output)
2622
1b2078bafdaa wiki parser tests: fixed line_anchor problems and some other broken tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2621
diff changeset
484 assert 'Example <ul><li style="list-style-type:none"><pre>You can use {{{brackets}}}</pre>' in output
2263
c1682ea7ed8c text_moin_wiki: fixed an other nesting {{{ }}} problem and added a new test
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2262
diff changeset
485
c1682ea7ed8c text_moin_wiki: fixed an other nesting {{{ }}} problem and added a new test
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2262
diff changeset
486 def testManyNestingPreBrackets(self):
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
487 """ tests two nestings ({{{ }}} and {{{ }}}) in one line for the wiki parser
2263
c1682ea7ed8c text_moin_wiki: fixed an other nesting {{{ }}} problem and added a new test
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2262
diff changeset
488 """
2623
5c6d61bf88c5 wiki parser tests: fixed some other broken tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2622
diff changeset
489 py.test.skip("Broken")
2263
c1682ea7ed8c text_moin_wiki: fixed an other nesting {{{ }}} problem and added a new test
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2262
diff changeset
490
3052
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2778
diff changeset
491 raw = """{{{{
2263
c1682ea7ed8c text_moin_wiki: fixed an other nesting {{{ }}} problem and added a new test
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2262
diff changeset
492 Test {{{brackets}}} and test {{{brackets}}}
3052
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2778
diff changeset
493 }}}}"""
2263
c1682ea7ed8c text_moin_wiki: fixed an other nesting {{{ }}} problem and added a new test
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2262
diff changeset
494 output = self.parse(raw)
c1682ea7ed8c text_moin_wiki: fixed an other nesting {{{ }}} problem and added a new test
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2262
diff changeset
495 output = ''.join(output)
2623
5c6d61bf88c5 wiki parser tests: fixed some other broken tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2622
diff changeset
496 expected = '<pre>Test {{{brackets}}} and test {{{brackets}}}'
5c6d61bf88c5 wiki parser tests: fixed some other broken tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2622
diff changeset
497 assert expected in output
2263
c1682ea7ed8c text_moin_wiki: fixed an other nesting {{{ }}} problem and added a new test
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2262
diff changeset
498
2526
860e7bf6c4cc add failing {{{ }}} test
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2516
diff changeset
499 def testMultipleShortPreSections(self):
860e7bf6c4cc add failing {{{ }}} test
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2516
diff changeset
500 """
860e7bf6c4cc add failing {{{ }}} test
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2516
diff changeset
501 tests two single {{{ }}} in one line
860e7bf6c4cc add failing {{{ }}} test
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2516
diff changeset
502 """
2623
5c6d61bf88c5 wiki parser tests: fixed some other broken tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2622
diff changeset
503 raw = 'def {{{ghi}}} jkl {{{mno}}}'
2526
860e7bf6c4cc add failing {{{ }}} test
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2516
diff changeset
504 output = ''.join(self.parse(raw))
2623
5c6d61bf88c5 wiki parser tests: fixed some other broken tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2622
diff changeset
505 expected = 'def <tt>ghi</tt> jkl <tt>mno</tt>'
2526
860e7bf6c4cc add failing {{{ }}} test
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2516
diff changeset
506 assert expected in output
2263
c1682ea7ed8c text_moin_wiki: fixed an other nesting {{{ }}} problem and added a new test
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2262
diff changeset
507
2371
7de0a5eebf76 first simple test for link markup, fails
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2362
diff changeset
508 class TestLinkingMarkup(ParserTestCase):
2774
9d63b942987a more link/transclusion markup tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2739
diff changeset
509 """ Test wiki link markup """
2371
7de0a5eebf76 first simple test for link markup, fails
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2362
diff changeset
510
7de0a5eebf76 first simple test for link markup, fails
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2362
diff changeset
511 text = 'AAA %s AAA'
7de0a5eebf76 first simple test for link markup, fails
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2362
diff changeset
512 needle = re.compile(text % r'(.+)')
2774
9d63b942987a more link/transclusion markup tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2739
diff changeset
513 _tests = [
2739
9fd4a16a08cc tests: some more wiki parser link markup tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2727
diff changeset
514 # test, expected
2775
9b43bd4e9e38 fix typos
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2774
diff changeset
515 ('SomeNonExistentPage', '<a class="nonexistent" href="./SomeNonExistentPage">SomeNonExistentPage</a>'),
2778
c8dd346f146e parser: anchor, bang_meta, relative pagelink fixes, more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2775
diff changeset
516 ('SomeNonExistentPage#anchor', '<a class="nonexistent" href="./SomeNonExistentPage#anchor">SomeNonExistentPage#anchor</a>'),
2739
9fd4a16a08cc tests: some more wiki parser link markup tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2727
diff changeset
517 ('[[something]]', '<a class="nonexistent" href="./something">something</a>'),
2774
9d63b942987a more link/transclusion markup tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2739
diff changeset
518 ('[[some thing]]', '<a class="nonexistent" href="./some%20thing">some thing</a>'),
2739
9fd4a16a08cc tests: some more wiki parser link markup tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2727
diff changeset
519 ('[[something|some text]]', '<a class="nonexistent" href="./something">some text</a>'),
2778
c8dd346f146e parser: anchor, bang_meta, relative pagelink fixes, more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2775
diff changeset
520 ('[[../something]]', '<a class="nonexistent" href="./something">../something</a>'),
c8dd346f146e parser: anchor, bang_meta, relative pagelink fixes, more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2775
diff changeset
521 ('[[/something]]', '<a class="nonexistent" href="./%s/something">/something</a>' % PAGENAME),
c8dd346f146e parser: anchor, bang_meta, relative pagelink fixes, more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2775
diff changeset
522 ('[[something#anchor]]', '<a class="nonexistent" href="./something#anchor">something#anchor</a>'),
3052
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2778
diff changeset
523 ('MoinMoin:something', '<a class="interwiki" href="http://moinmo.in/something" title="MoinMoin">something</a>'),
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2778
diff changeset
524 ('[[MoinMoin:something|some text]]', '<a class="interwiki" href="http://moinmo.in/something" title="MoinMoin">some text</a>'),
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2778
diff changeset
525 ('[[MoinMoin:with space]]', '<a class="interwiki" href="http://moinmo.in/with%20space" title="MoinMoin">with space</a>'),
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2778
diff changeset
526 ('[[MoinMoin:with space|some text]]', '<a class="interwiki" href="http://moinmo.in/with%20space" title="MoinMoin">some text</a>'),
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2778
diff changeset
527 # no interwiki:
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2778
diff changeset
528 ('[[ABC:n]]', '<a class="nonexistent" href="./ABC%3An">ABC:n</a>'), # finnish/swedish abbreviations / possessive
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2778
diff changeset
529 ('ABC:n', 'ABC:n'), # finnish/swedish abbreviations / possessive
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2778
diff changeset
530 ('lowercase:nointerwiki', 'lowercase:nointerwiki'),
2739
9fd4a16a08cc tests: some more wiki parser link markup tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2727
diff changeset
531 ('[[http://google.com/|google]]', '<a class="http" href="http://google.com/">google</a>'),
2774
9d63b942987a more link/transclusion markup tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2739
diff changeset
532 ]
2371
7de0a5eebf76 first simple test for link markup, fails
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2362
diff changeset
533
2774
9d63b942987a more link/transclusion markup tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2739
diff changeset
534 def testLinkFormating(self):
9d63b942987a more link/transclusion markup tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2739
diff changeset
535 """ parser.wiki: link formating """
2371
7de0a5eebf76 first simple test for link markup, fails
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2362
diff changeset
536 for test, expected in self._tests:
7de0a5eebf76 first simple test for link markup, fails
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2362
diff changeset
537 html = self.parse(self.text % test)
7de0a5eebf76 first simple test for link markup, fails
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2362
diff changeset
538 result = self.needle.search(html).group(1)
2375
f9b0d11a6569 use assert in linking test
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2373
diff changeset
539 assert result == expected
2774
9d63b942987a more link/transclusion markup tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2739
diff changeset
540
9d63b942987a more link/transclusion markup tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2739
diff changeset
541 def testLinkAttachment(self):
9d63b942987a more link/transclusion markup tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2739
diff changeset
542 html = self.parse("[[attachment:some file.txt]]")
9d63b942987a more link/transclusion markup tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2739
diff changeset
543 assert '<a ' in html
9d63b942987a more link/transclusion markup tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2739
diff changeset
544 assert 'href="' in html
9d63b942987a more link/transclusion markup tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2739
diff changeset
545 assert 'class="attachment nonexistent"' in html
9d63b942987a more link/transclusion markup tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2739
diff changeset
546 assert 'action=AttachFile' in html
9d63b942987a more link/transclusion markup tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2739
diff changeset
547 assert 'some+file.txt' in html
9d63b942987a more link/transclusion markup tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2739
diff changeset
548
9d63b942987a more link/transclusion markup tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2739
diff changeset
549 def testLinkAttachmentImage(self):
9d63b942987a more link/transclusion markup tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2739
diff changeset
550 html = self.parse("[[attachment:some file.png]]")
9d63b942987a more link/transclusion markup tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2739
diff changeset
551 assert '<a ' in html # must create a link
9d63b942987a more link/transclusion markup tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2739
diff changeset
552 assert 'href="' in html
9d63b942987a more link/transclusion markup tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2739
diff changeset
553 assert 'class="attachment nonexistent"' in html
9d63b942987a more link/transclusion markup tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2739
diff changeset
554 assert 'action=AttachFile' in html
9d63b942987a more link/transclusion markup tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2739
diff changeset
555 assert 'some+file.png' in html
9d63b942987a more link/transclusion markup tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2739
diff changeset
556
9d63b942987a more link/transclusion markup tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2739
diff changeset
557
9d63b942987a more link/transclusion markup tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2739
diff changeset
558 class TestTransclusionMarkup(ParserTestCase):
9d63b942987a more link/transclusion markup tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2739
diff changeset
559 """ Test wiki markup """
9d63b942987a more link/transclusion markup tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2739
diff changeset
560
9d63b942987a more link/transclusion markup tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2739
diff changeset
561 text = 'AAA %s AAA'
9d63b942987a more link/transclusion markup tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2739
diff changeset
562 needle = re.compile(text % r'(.+)')
9d63b942987a more link/transclusion markup tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2739
diff changeset
563 _tests = [
9d63b942987a more link/transclusion markup tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2739
diff changeset
564 # test, expected
9d63b942987a more link/transclusion markup tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2739
diff changeset
565 ('{{http://moinmo.in/wiki/common/moinmoin.png}}', '<img alt="http://moinmo.in/wiki/common/moinmoin.png" class="external_image" src="http://moinmo.in/wiki/common/moinmoin.png" title="http://moinmo.in/wiki/common/moinmoin.png" />'),
9d63b942987a more link/transclusion markup tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2739
diff changeset
566 ('{{http://moinmo.in/wiki/common/moinmoin.png|moin logo}}', '<img alt="moin logo" class="external_image" src="http://moinmo.in/wiki/common/moinmoin.png" title="moin logo" />'),
9d63b942987a more link/transclusion markup tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2739
diff changeset
567 ]
9d63b942987a more link/transclusion markup tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2739
diff changeset
568
9d63b942987a more link/transclusion markup tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2739
diff changeset
569 def testTransclusionFormating(self):
9d63b942987a more link/transclusion markup tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2739
diff changeset
570 """ parser.wiki: transclusion formating """
9d63b942987a more link/transclusion markup tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2739
diff changeset
571 for test, expected in self._tests:
9d63b942987a more link/transclusion markup tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2739
diff changeset
572 html = self.parse(self.text % test)
9d63b942987a more link/transclusion markup tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2739
diff changeset
573 result = self.needle.search(html).group(1)
9d63b942987a more link/transclusion markup tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2739
diff changeset
574 assert result == expected
2378
a7f4b02f5fdb fix the quoting mess
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2375
diff changeset
575
2448
c9949c55ff5e add coverage_modules attribute for coverage testing
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2378
diff changeset
576
c9949c55ff5e add coverage_modules attribute for coverage testing
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2378
diff changeset
577 coverage_modules = ['MoinMoin.parser.text_moin_wiki']
2624
3d30e923448f wiki parser tests: convert to py.test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2623
diff changeset
578