annotate MoinMoin/parser/_tests/test_text_moin_wiki.py @ 2624:3d30e923448f

wiki parser tests: convert to py.test
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Fri, 10 Aug 2007 12:10:20 +0200
parents 5c6d61bf88c5
children 388204baf00f
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
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
21
2624
3d30e923448f wiki parser tests: convert to py.test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2623
diff changeset
22 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
23 """ 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
24
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
25 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
26 """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
27
691b6a650d94 test_text_moin_wiki: moved to _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 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
29 """
2621
6bb7cad1a039 tests: simplify parser test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2572
diff changeset
30 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
31 assert body is not None
2621
6bb7cad1a039 tests: simplify parser test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2572
diff changeset
32 request.reset()
6bb7cad1a039 tests: simplify parser test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2572
diff changeset
33 page = Page(request, '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
34 page.hilite_re = None
2621
6bb7cad1a039 tests: simplify parser test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2572
diff changeset
35 page.set_raw_body(body)
6bb7cad1a039 tests: simplify parser test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2572
diff changeset
36 formatter = HtmlFormatter(request)
6bb7cad1a039 tests: simplify parser test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2572
diff changeset
37 formatter.setPage(page)
6bb7cad1a039 tests: simplify parser test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2572
diff changeset
38 page.formatter = formatter
6bb7cad1a039 tests: simplify parser test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2572
diff changeset
39 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
40 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
41 formatter.startContent('') # needed for _include_stack init
6bb7cad1a039 tests: simplify parser test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2572
diff changeset
42 output = request.redirectedOutput(parser.format, formatter)
6bb7cad1a039 tests: simplify parser test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2572
diff changeset
43 formatter.endContent('')
6bb7cad1a039 tests: simplify parser test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2572
diff changeset
44 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
45
691b6a650d94 test_text_moin_wiki: moved to _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 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
48 """ 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
49
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
50 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
51 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
52 """
691b6a650d94 test_text_moin_wiki: moved to _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 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
55 """ 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
56 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
57 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
58
691b6a650d94 test_text_moin_wiki: moved to _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 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
60 """ 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
61 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
62 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
63
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
64 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
65 """ 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
66
691b6a650d94 test_text_moin_wiki: moved to _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 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
68 '----\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
69 '|| 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
70 '= 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
71 '== 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
72 '=== 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
73 '==== 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
74 '===== heading 5 =====\n',
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
75 # '[[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
76 )
691b6a650d94 test_text_moin_wiki: moved to _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 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
78 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
79 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
80 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
81
691b6a650d94 test_text_moin_wiki: moved to _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 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
84 """ 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
85
2624
3d30e923448f wiki parser tests: convert to py.test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2623
diff changeset
86 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
87 """ 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
88 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
89 """
691b6a650d94 test_text_moin_wiki: moved to _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 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
91
2624
3d30e923448f wiki parser tests: convert to py.test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2623
diff changeset
92 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
93 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
94
691b6a650d94 test_text_moin_wiki: moved to _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 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
96 """ 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
97
691b6a650d94 test_text_moin_wiki: moved to _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 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
99
691b6a650d94 test_text_moin_wiki: moved to _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 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
101 """
691b6a650d94 test_text_moin_wiki: moved to _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 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
103 '= 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
104 '= 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
105 '= 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
106 )
691b6a650d94 test_text_moin_wiki: moved to _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 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
108 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
109 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
110 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
111
691b6a650d94 test_text_moin_wiki: moved to _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 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
114
2624
3d30e923448f wiki parser tests: convert to py.test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2623
diff changeset
115 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
116 """ 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
117 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
118 """
691b6a650d94 test_text_moin_wiki: moved to _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 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
120
2624
3d30e923448f wiki parser tests: convert to py.test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2623
diff changeset
121 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
122 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
123
691b6a650d94 test_text_moin_wiki: moved to _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 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
125 """ 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
126
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
127 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
128
691b6a650d94 test_text_moin_wiki: moved to _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 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
130 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
131 """
691b6a650d94 test_text_moin_wiki: moved to _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 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
133 [[TableOfContents]]
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
134 = 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
135 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
136 """
691b6a650d94 test_text_moin_wiki: moved to _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 withWhitespace = """
691b6a650d94 test_text_moin_wiki: moved to _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 [[TableOfContents]]
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
139 = 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
140 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
141 """
691b6a650d94 test_text_moin_wiki: moved to _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 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
143 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
144 assert result == expected
2261
7e04a576e8c7 test_text_moin_wiki: small PEP8 changes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2258
diff changeset
145
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
146
691b6a650d94 test_text_moin_wiki: moved to _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 class TestDateTimeMacro(ParserTestCase):
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
148 """ Test DateTime macro
2261
7e04a576e8c7 test_text_moin_wiki: small PEP8 changes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2258
diff changeset
149
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
150 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
151 * 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
152 * 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
153 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
154 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
155 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
156 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
157 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
158 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
159
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
160 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
161 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
162 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
163 """
2261
7e04a576e8c7 test_text_moin_wiki: small PEP8 changes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2258
diff changeset
164
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
165 text = 'AAA %s AAA'
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
166 needle = re.compile(text % r'(.+)')
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
167 _tests = (
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
168 # test expected
2535
52961e122768 fix tests, using unicode instead of str
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2533
diff changeset
169 (u'[[DateTime(259200)]]', '1970-01-04 00:00:00'),
52961e122768 fix tests, using unicode instead of str
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2533
diff changeset
170 (u'[[DateTime(2003-03-03T03:03:03)]]', '2003-03-03 03:03:03'),
52961e122768 fix tests, using unicode instead of str
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2533
diff changeset
171 (u'[[DateTime(2000-01-01T00:00:00Z)]]', '2000-01-01 00:00:00'), # works for Europe/Vilnius
52961e122768 fix tests, using unicode instead of str
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2533
diff changeset
172 (u'[[Date(2002-02-02T01:02:03Z)]]', '2002-02-02'),
52961e122768 fix tests, using unicode instead of str
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2533
diff changeset
173 (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
174 )
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
175
2624
3d30e923448f wiki parser tests: convert to py.test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2623
diff changeset
176 def class_setup(self):
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
177 """ 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
178 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
179
2624
3d30e923448f wiki parser tests: convert to py.test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2623
diff changeset
180 def class_teardown(self):
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
181 del self.config
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
182
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
183 def testDateTimeMacro(self):
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
184 """ parser.wiki: DateTime macro """
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
185 note = """
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
186
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
187 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
188 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
189
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
190 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
191 """
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
192
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
193 for test, expected in self._tests:
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
194 html = self.parse(self.text % test)
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
195 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
196 assert result == expected
2261
7e04a576e8c7 test_text_moin_wiki: small PEP8 changes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2258
diff changeset
197
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
198
691b6a650d94 test_text_moin_wiki: moved to _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 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
200 """ Test wiki markup """
2261
7e04a576e8c7 test_text_moin_wiki: small PEP8 changes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2258
diff changeset
201
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
202 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
203 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
204 _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
205 # 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
206 ('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
207 ("''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
208 ("'''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
209 ("__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
210 ("'''''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
211 ("'''''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
212 ("'''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
213 ("''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
214 )
2261
7e04a576e8c7 test_text_moin_wiki: small PEP8 changes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2258
diff changeset
215
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
216 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
217 """ 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
218 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
219 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
220 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
221 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
222
691b6a650d94 test_text_moin_wiki: moved to _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 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
225
691b6a650d94 test_text_moin_wiki: moved to _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 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
227 """ 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
228 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
229 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
230 # 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
231 ("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
232 ("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
233 ("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
234 ("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
235 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
236 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
237 )
691b6a650d94 test_text_moin_wiki: moved to _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 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
239 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
240 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
241
691b6a650d94 test_text_moin_wiki: moved to _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 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
244 """
691b6a650d94 test_text_moin_wiki: moved to _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 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
246 """
2261
7e04a576e8c7 test_text_moin_wiki: small PEP8 changes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2258
diff changeset
247
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
248 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
249 """ 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
250
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
251 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
252 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
253 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
254 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
255
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
256
691b6a650d94 test_text_moin_wiki: moved to _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 class TestEscapeHTML(ParserTestCase):
2261
7e04a576e8c7 test_text_moin_wiki: small PEP8 changes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2258
diff changeset
258
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
259 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
260 """ 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
261 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
262 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
263
691b6a650d94 test_text_moin_wiki: moved to _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 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
265 """ 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
266 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
267 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
268
691b6a650d94 test_text_moin_wiki: moved to _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 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
270 """ 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
271 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
272 <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
273 }}}
691b6a650d94 test_text_moin_wiki: moved to _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 self._test(test)
2261
7e04a576e8c7 test_text_moin_wiki: small PEP8 changes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2258
diff changeset
276
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
277 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
278 """ 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
279 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
280 <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
281 }}}
691b6a650d94 test_text_moin_wiki: moved to _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 self._test(test)
2261
7e04a576e8c7 test_text_moin_wiki: small PEP8 changes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2258
diff changeset
284
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
285 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
286 """ 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
287 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
288 #<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
289 }}}
691b6a650d94 test_text_moin_wiki: moved to _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 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
292
691b6a650d94 test_text_moin_wiki: moved to _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 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
294 """ parser.wiki: escape html markup in GetText macro """
691b6a650d94 test_text_moin_wiki: moved to _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 test = "text [[GetText(<escape-me>)]] 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
296 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
297
691b6a650d94 test_text_moin_wiki: moved to _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 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
299 """ parser.wiki: escape html markup in getText formatted call """
691b6a650d94 test_text_moin_wiki: moved to _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 test = self.request.getText('<escape-me>', formatted=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
301 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
302
691b6a650d94 test_text_moin_wiki: moved to _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 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
304 """ parser.wiki: escape html markup in getText formatted call with link """
691b6a650d94 test_text_moin_wiki: moved to _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 test = self.request.getText('["<escape-me>"]', formatted=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
306 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
307
691b6a650d94 test_text_moin_wiki: moved to _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 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
309 """ parser.wiki: escape html markup in getText non formatted call """
691b6a650d94 test_text_moin_wiki: moved to _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 test = self.request.getText('<escape-me>', formatted=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
311 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
312
691b6a650d94 test_text_moin_wiki: moved to _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 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
314 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
315 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
316 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
317
691b6a650d94 test_text_moin_wiki: moved to _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 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
320
691b6a650d94 test_text_moin_wiki: moved to _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 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
322 """ 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
323 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
324 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
325
691b6a650d94 test_text_moin_wiki: moved to _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 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
327 """ 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
328 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
329 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
330
691b6a650d94 test_text_moin_wiki: moved to _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 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
332 """ 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
333 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
334 ||<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
335 }}}
691b6a650d94 test_text_moin_wiki: moved to _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 self.do(test)
2261
7e04a576e8c7 test_text_moin_wiki: small PEP8 changes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2258
diff changeset
338
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
339 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
340 """ 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
341 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
342 ||<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
343 }}}
691b6a650d94 test_text_moin_wiki: moved to _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 self.do(test)
2261
7e04a576e8c7 test_text_moin_wiki: small PEP8 changes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2258
diff changeset
346
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
347 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
348 """ 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
349 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
350 # ||<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
351 }}}
691b6a650d94 test_text_moin_wiki: moved to _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 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
354
691b6a650d94 test_text_moin_wiki: moved to _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 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
356 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
357 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
358 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
359
691b6a650d94 test_text_moin_wiki: moved to _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 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
362 """ 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
363
691b6a650d94 test_text_moin_wiki: moved to _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 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
365 """ 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
366 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
367 expected = '---' # inside <p>
2624
3d30e923448f wiki parser tests: convert to py.test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2623
diff changeset
368 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
369
691b6a650d94 test_text_moin_wiki: moved to _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 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
371 """ 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
372 result = self.parse('----')
2624
3d30e923448f wiki parser tests: convert to py.test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2623
diff changeset
373 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
374
691b6a650d94 test_text_moin_wiki: moved to _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 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
376 """ 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
377
691b6a650d94 test_text_moin_wiki: moved to _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 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
379 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
380 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
381 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
382
691b6a650d94 test_text_moin_wiki: moved to _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 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
384 """ 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
385 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
386 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
387 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
388
691b6a650d94 test_text_moin_wiki: moved to _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 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
391 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
392 # 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
393 ('----\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
394 ('= 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
395 ('{{{\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
396 ('{{{\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
397 ('|| 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
398 (' * 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
399 (' 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
400 (' 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
401 )
691b6a650d94 test_text_moin_wiki: moved to _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 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
404 """ 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
405 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
406 %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
407 """
691b6a650d94 test_text_moin_wiki: moved to _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 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
409 # 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
410 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
411 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
412 result = self.parse(text % test)
2624
3d30e923448f wiki parser tests: convert to py.test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2623
diff changeset
413 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
414
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
415 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
416 """ 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
417
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
418 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
419 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
420
691b6a650d94 test_text_moin_wiki: moved to _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 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
422 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
423 """
691b6a650d94 test_text_moin_wiki: moved to _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 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
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 %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
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 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
429 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
430 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
431 result = self.parse(text % test)
2624
3d30e923448f wiki parser tests: convert to py.test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2623
diff changeset
432 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
433
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
434 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
435 """ 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
436 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
437
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
438 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
439 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
440
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 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
442 """ 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
443 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
444
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 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
446 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
447
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
448 def testColorizedPythonParserAndNestingPreBrackets(self):
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
449 """ 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
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
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
452 raw = """{{{
691b6a650d94 test_text_moin_wiki: moved to _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 #!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
454 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
455 pattern = re.compile(r'{{{This is some nested 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
456 output = self.parse(raw)
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
457 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
458 assert "r'{{{This is some nested text}}}'" in output
2261
7e04a576e8c7 test_text_moin_wiki: small PEP8 changes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2258
diff changeset
459
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
460 def testColorizedPythonParserAndNestingPreBracketsWithLinebreak(self):
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
461 """ tests nested {{{ }}} for the python colorized 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
462 """
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
463
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
464 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
465 #!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
466 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
467 pattern = re.compile(r'{{{This is some nested text}}}')
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 }}}"""
9c66c14f6b62 text_moin_wiki: completing nesting for colorized parsers and some tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2256
diff changeset
469 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
470 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
471 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
472
9c66c14f6b62 text_moin_wiki: completing nesting for colorized parsers and some tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2256
diff changeset
473 def testNestingPreBrackets(self):
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
474 """ 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
475 """
9c66c14f6b62 text_moin_wiki: completing nesting for colorized parsers and some tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2256
diff changeset
476
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 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
478 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
479 You can use {{{brackets}}}}}}"""
9c66c14f6b62 text_moin_wiki: completing nesting for colorized parsers and some tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2256
diff changeset
480 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
481 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
482 assert 'You can use {{{brackets}}}' in output
2261
7e04a576e8c7 test_text_moin_wiki: small PEP8 changes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2258
diff changeset
483
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
484 def testNestingPreBracketsWithLinebreak(self):
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
485 """ 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
486 """
9c66c14f6b62 text_moin_wiki: completing nesting for colorized parsers and some tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2256
diff changeset
487
9c66c14f6b62 text_moin_wiki: completing nesting for colorized parsers and some tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2256
diff changeset
488 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
489 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
490 You can use {{{brackets}}}
9c66c14f6b62 text_moin_wiki: completing nesting for colorized parsers and some tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2256
diff changeset
491 }}}"""
9c66c14f6b62 text_moin_wiki: completing nesting for colorized parsers and some tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2256
diff changeset
492 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
493 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
494 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
495 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
496
9c66c14f6b62 text_moin_wiki: completing nesting for colorized parsers and some tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2256
diff changeset
497 def testTextBeforeNestingPreBrackets(self):
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
498 """ 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
499 """
9c66c14f6b62 text_moin_wiki: completing nesting for colorized parsers and some tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2256
diff changeset
500 raw = """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
501 {{{
9c66c14f6b62 text_moin_wiki: completing nesting for colorized parsers and some tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2256
diff changeset
502 You can use {{{brackets}}}}}}"""
9c66c14f6b62 text_moin_wiki: completing nesting for colorized parsers and some tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2256
diff changeset
503 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
504 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
505 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
506
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 def testManyNestingPreBrackets(self):
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
508 """ 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
509 """
2623
5c6d61bf88c5 wiki parser tests: fixed some other broken tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2622
diff changeset
510 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
511
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
512 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
513 Test {{{brackets}}} and test {{{brackets}}}
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
514 }}}"""
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
515 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
516 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
517 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
518 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
519
2526
860e7bf6c4cc add failing {{{ }}} test
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2516
diff changeset
520 def testMultipleShortPreSections(self):
860e7bf6c4cc add failing {{{ }}} test
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2516
diff changeset
521 """
860e7bf6c4cc add failing {{{ }}} test
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2516
diff changeset
522 tests two single {{{ }}} in one line
860e7bf6c4cc add failing {{{ }}} test
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2516
diff changeset
523 """
2623
5c6d61bf88c5 wiki parser tests: fixed some other broken tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2622
diff changeset
524 raw = 'def {{{ghi}}} jkl {{{mno}}}'
2526
860e7bf6c4cc add failing {{{ }}} test
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2516
diff changeset
525 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
526 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
527 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
528
2371
7de0a5eebf76 first simple test for link markup, fails
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2362
diff changeset
529 class TestLinkingMarkup(ParserTestCase):
7de0a5eebf76 first simple test for link markup, fails
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2362
diff changeset
530 """ Test wiki markup """
7de0a5eebf76 first simple test for link markup, fails
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2362
diff changeset
531
7de0a5eebf76 first simple test for link markup, fails
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2362
diff changeset
532 text = 'AAA %s AAA'
7de0a5eebf76 first simple test for link markup, fails
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2362
diff changeset
533 needle = re.compile(text % r'(.+)')
7de0a5eebf76 first simple test for link markup, fails
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2362
diff changeset
534 _tests = (
2372
704c1051e73f more link tests as I expect things to behave
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2371
diff changeset
535 # test, expected
704c1051e73f more link tests as I expect things to behave
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2371
diff changeset
536 ('["something"]', '<a class="nonexistent" href="./something">something</a>'),
704c1051e73f more link tests as I expect things to behave
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2371
diff changeset
537 ("['something']", "['something']"),
704c1051e73f more link tests as I expect things to behave
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2371
diff changeset
538 ('MoinMoin:"something"', '<a class="interwiki" href="http://moinmoin.wikiwikiweb.de/something" title="MoinMoin">something</a>'),
2373
7e7560f2cddd more tests for linking
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2372
diff changeset
539 ('MoinMoin:"with space"', '<a class="interwiki" href="http://moinmoin.wikiwikiweb.de/with%20space" title="MoinMoin">with space</a>'),
7e7560f2cddd more tests for linking
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2372
diff changeset
540 ('RFC:"1 2 3"', '<a class="interwiki" href="http://www.ietf.org/rfc/rfc1%202%203" title="RFC">1 2 3</a>'),
7e7560f2cddd more tests for linking
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2372
diff changeset
541 ("RFC:'something else'", "RFC:'something else'"),
2378
a7f4b02f5fdb fix the quoting mess
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2375
diff changeset
542 ('["with "" quote"]', '<a class="nonexistent" href="./with%20%22%20quote">with " quote</a>'),
a7f4b02f5fdb fix the quoting mess
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2375
diff changeset
543 ('MoinMoin:"with "" quote"', '<a class="interwiki" href="http://moinmoin.wikiwikiweb.de/with%20%22%20quote" title="MoinMoin">with " quote</a>'),
2371
7de0a5eebf76 first simple test for link markup, fails
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2362
diff changeset
544 )
7de0a5eebf76 first simple test for link markup, fails
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2362
diff changeset
545
7de0a5eebf76 first simple test for link markup, fails
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2362
diff changeset
546 def testTextFormating(self):
7de0a5eebf76 first simple test for link markup, fails
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2362
diff changeset
547 """ parser.wiki: text formating """
2378
a7f4b02f5fdb fix the quoting mess
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2375
diff changeset
548 together_test = []
a7f4b02f5fdb fix the quoting mess
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2375
diff changeset
549 together_expected = []
2371
7de0a5eebf76 first simple test for link markup, fails
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2362
diff changeset
550 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
551 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
552 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
553 assert result == expected
2378
a7f4b02f5fdb fix the quoting mess
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2375
diff changeset
554 together_test.append(test)
a7f4b02f5fdb fix the quoting mess
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2375
diff changeset
555 together_expected.append(expected)
a7f4b02f5fdb fix the quoting mess
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2375
diff changeset
556
a7f4b02f5fdb fix the quoting mess
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2375
diff changeset
557 # now test all together to make sure one quoting doesn't
a7f4b02f5fdb fix the quoting mess
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2375
diff changeset
558 # "leak" into the next
a7f4b02f5fdb fix the quoting mess
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2375
diff changeset
559 for joint in ('', 'lala " lala ', 'lala "" lala '):
a7f4b02f5fdb fix the quoting mess
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2375
diff changeset
560 test = joint.join(together_test)
a7f4b02f5fdb fix the quoting mess
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2375
diff changeset
561 expected = joint.join(together_expected)
a7f4b02f5fdb fix the quoting mess
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2375
diff changeset
562 html = self.parse(self.text % test)
a7f4b02f5fdb fix the quoting mess
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2375
diff changeset
563 result = self.needle.search(html).group(1)
a7f4b02f5fdb fix the quoting mess
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2375
diff changeset
564 assert result == expected
2448
c9949c55ff5e add coverage_modules attribute for coverage testing
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2378
diff changeset
565
c9949c55ff5e add coverage_modules attribute for coverage testing
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2378
diff changeset
566
c9949c55ff5e add coverage_modules attribute for coverage testing
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2378
diff changeset
567 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
568