annotate MoinMoin/parser/_tests/test_text_moin_wiki.py @ 6095:465cb6f5c6d7

moin code fixes needed for werkzeug 0.11.11 werkzeug.escape now also escapes quotes. Headers are a datatype now, not a simple list any more.
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Mon, 05 Sep 2016 23:29:03 +0200
parents b82318102f22
children
rev   line source
2256
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
1 # -*- coding: iso-8859-1 -*-
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
2 """
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
3 MoinMoin - MoinMoin.parser.text_moin_wiki Tests
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
4
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
5 TODO: these are actually parser+formatter tests. We should have
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
6 parser only tests here.
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
7
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
8 @copyright: 2003-2004 by Juergen Hermann <jh@web.de>
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
9 @license: GNU GPL, see COPYING for details.
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
10 """
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
11
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
12 import re
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
13 from StringIO import StringIO
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
14
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
15 import py
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
16
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
17 from MoinMoin.Page import Page
2621
6bb7cad1a039 tests: simplify parser test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2572
diff changeset
18 from MoinMoin.parser.text_moin_wiki import Parser as WikiParser
6bb7cad1a039 tests: simplify parser test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2572
diff changeset
19 from MoinMoin.formatter.text_html import Formatter as HtmlFormatter
2256
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
20
2778
c8dd346f146e parser: anchor, bang_meta, relative pagelink fixes, more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2775
diff changeset
21 PAGENAME = u'ThisPageDoesNotExistsAndWillNeverBeReally'
2256
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
22
2624
3d30e923448f wiki parser tests: convert to py.test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2623
diff changeset
23 class ParserTestCase(object):
2256
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
24 """ Helper class that provide a parsing method """
2261
7e04a576e8c7 test_text_moin_wiki: small PEP8 changes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2258
diff changeset
25
2256
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
26 def parse(self, body):
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
27 """Parse body and return html
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
28
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
29 Create a page with body, then parse it and format using html formatter
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
30 """
2621
6bb7cad1a039 tests: simplify parser test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2572
diff changeset
31 request = self.request
2256
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
32 assert body is not None
2621
6bb7cad1a039 tests: simplify parser test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2572
diff changeset
33 request.reset()
2778
c8dd346f146e parser: anchor, bang_meta, relative pagelink fixes, more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2775
diff changeset
34 page = Page(request, PAGENAME)
2256
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
35 page.hilite_re = None
2621
6bb7cad1a039 tests: simplify parser test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2572
diff changeset
36 page.set_raw_body(body)
6bb7cad1a039 tests: simplify parser test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2572
diff changeset
37 formatter = HtmlFormatter(request)
6bb7cad1a039 tests: simplify parser test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2572
diff changeset
38 formatter.setPage(page)
6bb7cad1a039 tests: simplify parser test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2572
diff changeset
39 page.formatter = formatter
6bb7cad1a039 tests: simplify parser test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2572
diff changeset
40 request.formatter = formatter
2622
1b2078bafdaa wiki parser tests: fixed line_anchor problems and some other broken tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2621
diff changeset
41 parser = WikiParser(body, request, line_anchors=False)
2621
6bb7cad1a039 tests: simplify parser test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2572
diff changeset
42 formatter.startContent('') # needed for _include_stack init
6bb7cad1a039 tests: simplify parser test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2572
diff changeset
43 output = request.redirectedOutput(parser.format, formatter)
6bb7cad1a039 tests: simplify parser test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2572
diff changeset
44 formatter.endContent('')
6bb7cad1a039 tests: simplify parser test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2572
diff changeset
45 return output
2256
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
46
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
47
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
48 class TestParagraphs(ParserTestCase):
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
49 """ Test paragraphs creating
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
50
2622
1b2078bafdaa wiki parser tests: fixed line_anchor problems and some other broken tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2621
diff changeset
51 All tests ignoring white space in output.
1b2078bafdaa wiki parser tests: fixed line_anchor problems and some other broken tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2621
diff changeset
52 We do not test for </p> as it is not there currently.
2256
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
53 """
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
54
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
55 def testFirstParagraph(self):
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
56 """ parser.wiki: first paragraph should be in <p> """
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
57 result = self.parse('First')
2624
3d30e923448f wiki parser tests: convert to py.test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2623
diff changeset
58 assert re.search(r'<p.*?>\s*First\s*', result)
2256
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
59
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
60 def testEmptyLineBetweenParagraphs(self):
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
61 """ parser.wiki: empty line separates paragraphs """
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
62 result = self.parse('First\n\nSecond')
2624
3d30e923448f wiki parser tests: convert to py.test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2623
diff changeset
63 assert re.search(r'<p.*?>\s*Second\s*', result)
2261
7e04a576e8c7 test_text_moin_wiki: small PEP8 changes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2258
diff changeset
64
2256
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
65 def testParagraphAfterBlockMarkup(self):
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
66 """ parser.wiki: create paragraph after block markup """
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
67
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
68 markup = (
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
69 '----\n',
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
70 '|| table ||\n',
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
71 '= heading 1 =\n',
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
72 '== heading 2 ==\n',
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
73 '=== heading 3 ===\n',
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
74 '==== heading 4 ====\n',
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
75 '===== heading 5 =====\n',
2725
388204baf00f change [[macro]] to <<macro>> in all built-in markup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2624
diff changeset
76 # '<<en>>\n', XXX crashes
2256
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
77 )
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
78 for item in markup:
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
79 text = item + 'Paragraph'
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
80 result = self.parse(text)
2624
3d30e923448f wiki parser tests: convert to py.test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2623
diff changeset
81 assert re.search(r'<p.*?>\s*Paragraph\s*', result)
2256
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
82
3217
b06c048233f2 add a new (failing) test, do not skip a (now) working test, fix small trailing whitespace issue
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3143
diff changeset
83 def testStrangeP(self):
b06c048233f2 add a new (failing) test, do not skip a (now) working test, fix small trailing whitespace issue
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3143
diff changeset
84 """ parser.wiki: empty line separates paragraphs """
b06c048233f2 add a new (failing) test, do not skip a (now) working test, fix small trailing whitespace issue
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3143
diff changeset
85 result = self.parse("""<<BR>> <<BR>>
b06c048233f2 add a new (failing) test, do not skip a (now) working test, fix small trailing whitespace issue
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3143
diff changeset
86
b06c048233f2 add a new (failing) test, do not skip a (now) working test, fix small trailing whitespace issue
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3143
diff changeset
87 foo ''bar'' baz.
b06c048233f2 add a new (failing) test, do not skip a (now) working test, fix small trailing whitespace issue
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3143
diff changeset
88 """)
b06c048233f2 add a new (failing) test, do not skip a (now) working test, fix small trailing whitespace issue
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3143
diff changeset
89 assert re.search(r'foo <em>bar</em> baz', result)
b06c048233f2 add a new (failing) test, do not skip a (now) working test, fix small trailing whitespace issue
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3143
diff changeset
90
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
91
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
92 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
93 """ 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
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
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
115 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
116 """ 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
117
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
118 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
119
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
120 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
121 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
122 """
691b6a650d94 test_text_moin_wiki: moved to _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 standard = """
2725
388204baf00f change [[macro]] to <<macro>> in all built-in markup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2624
diff changeset
124 <<TableOfContents>>
2256
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
125 = 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
126 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
127 """
691b6a650d94 test_text_moin_wiki: moved to _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 withWhitespace = """
2725
388204baf00f change [[macro]] to <<macro>> in all built-in markup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2624
diff changeset
129 <<TableOfContents>>
2256
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
130 = 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
131 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
132 """
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
133 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
134 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
135 assert result == expected
2261
7e04a576e8c7 test_text_moin_wiki: small PEP8 changes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2258
diff changeset
136
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
137
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
138 class TestDateTimeMacro(ParserTestCase):
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
139 """ Test DateTime macro
2261
7e04a576e8c7 test_text_moin_wiki: small PEP8 changes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2258
diff changeset
140
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
141 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
142 * 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
143 * 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
144 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
145 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
146 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
147 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
148 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
149 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
150
2292
953a0e4e3dac tests: document some DateTime timezone related test failure we can't easily fix for some special cases
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2286
diff changeset
151 If 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
152 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
153 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
154 """
2261
7e04a576e8c7 test_text_moin_wiki: small PEP8 changes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2258
diff changeset
155
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
156 text = 'AAA %s AAA'
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
157 needle = re.compile(text % r'(.+)')
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
158 _tests = (
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
159 # test expected
2725
388204baf00f change [[macro]] to <<macro>> in all built-in markup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2624
diff changeset
160 (u'<<DateTime(259200)>>', '1970-01-04 00:00:00'),
388204baf00f change [[macro]] to <<macro>> in all built-in markup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2624
diff changeset
161 (u'<<DateTime(2003-03-03T03:03:03)>>', '2003-03-03 03:03:03'),
388204baf00f change [[macro]] to <<macro>> in all built-in markup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2624
diff changeset
162 (u'<<DateTime(2000-01-01T00:00:00Z)>>', '2000-01-01 00:00:00'), # works for Europe/Vilnius
388204baf00f change [[macro]] to <<macro>> in all built-in markup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2624
diff changeset
163 (u'<<Date(2002-02-02T01:02:03Z)>>', '2002-02-02'),
4750
617c9c236bf0 (xorAxAx with safe) Comment out the last datetime test tuple even though it is showing a bug in moin. But we think that the problem is showing up too seldomly to be seen by users.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 4411
diff changeset
164 #(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
165 )
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
166
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
167 def testDateTimeMacro(self):
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
168 """ parser.wiki: DateTime macro """
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
169 note = """
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
170
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
171 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
172 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
173
4750
617c9c236bf0 (xorAxAx with safe) Comment out the last datetime test tuple even though it is showing a bug in moin. But we think that the problem is showing up too seldomly to be seen by users.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 4411
diff changeset
174 It can also be related to TZ changes a country historically made and then
617c9c236bf0 (xorAxAx with safe) Comment out the last datetime test tuple even though it is showing a bug in moin. But we think that the problem is showing up too seldomly to be seen by users.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 4411
diff changeset
175 shows a bug in moin. For this reason, the last tuple above is commented out.
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
176 """
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
177
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
178 for test, expected in self._tests:
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
179 html = self.parse(self.text % test)
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
180 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
181 assert result == expected
2261
7e04a576e8c7 test_text_moin_wiki: small PEP8 changes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2258
diff changeset
182
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
183
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
184 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
185 """ Test wiki markup """
2261
7e04a576e8c7 test_text_moin_wiki: small PEP8 changes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2258
diff changeset
186
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
187 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
188 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
189 _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
190 # 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
191 ('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
192 ("''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
193 ("'''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
194 ("__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
195 ("'''''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
196 ("'''''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
197 ("'''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
198 ("''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
199 )
2261
7e04a576e8c7 test_text_moin_wiki: small PEP8 changes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2258
diff changeset
200
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
201 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
202 """ 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
203 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
204 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
205 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
206 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
207
691b6a650d94 test_text_moin_wiki: moved to _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
691b6a650d94 test_text_moin_wiki: moved to _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 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
210
691b6a650d94 test_text_moin_wiki: moved to _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 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
212 """ 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
213 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
214 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
215 # test, expected
3217
b06c048233f2 add a new (failing) test, do not skip a (now) working test, fix small trailing whitespace issue
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3143
diff changeset
216 ("text__text\n", r'<p[^>]*>text<span class="u">text\s*</span></p>'),
b06c048233f2 add a new (failing) test, do not skip a (now) working test, fix small trailing whitespace issue
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3143
diff changeset
217 ("text''text\n", r'<p[^>]*>text<em>text\s*</em></p>'),
b06c048233f2 add a new (failing) test, do not skip a (now) working test, fix small trailing whitespace issue
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3143
diff changeset
218 ("text'''text\n", r'<p[^>]*>text<strong>text\s*</strong></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
219 ("text ''em '''em strong __em strong underline",
3217
b06c048233f2 add a new (failing) test, do not skip a (now) working test, fix small trailing whitespace issue
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3143
diff changeset
220 r'text <em>em <strong>em strong <span class="u">em strong underline'
b06c048233f2 add a new (failing) test, do not skip a (now) working test, fix small trailing whitespace issue
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3143
diff changeset
221 r'\s*</span></strong></em></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
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 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
224 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
225 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
226
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
227
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
228 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
229 """
691b6a650d94 test_text_moin_wiki: moved to _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 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
231 """
2261
7e04a576e8c7 test_text_moin_wiki: small PEP8 changes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2258
diff changeset
232
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
233 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
234 """ 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
235
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
236 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
237 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
238 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
239 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
240
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 class TestEscapeHTML(ParserTestCase):
2261
7e04a576e8c7 test_text_moin_wiki: small PEP8 changes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2258
diff changeset
243
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
244 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
245 """ 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
246 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
247 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
248
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
249 def 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
250 """ 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
251 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
252 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
253
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
254 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
255 """ 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
256 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
257 <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
258 }}}
691b6a650d94 test_text_moin_wiki: moved to _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 '''
691b6a650d94 test_text_moin_wiki: moved to _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 self._test(test)
2261
7e04a576e8c7 test_text_moin_wiki: small PEP8 changes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2258
diff changeset
261
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
262 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
263 """ 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
264 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
265 <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
266 }}}
691b6a650d94 test_text_moin_wiki: moved to _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 '''
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
268 self._test(test)
2261
7e04a576e8c7 test_text_moin_wiki: small PEP8 changes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2258
diff changeset
269
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
270 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
271 """ 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
272 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
273 #<escape-me>
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
274 }}}
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
275 '''
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
276 self._test(test)
691b6a650d94 test_text_moin_wiki: moved to _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
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
278 def 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
279 """ parser.wiki: escape html markup in GetText macro """
3244
886b8969dbc6 fix some unit tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3221
diff changeset
280 test = u"text <<GetText(<escape-me>)>> text"
2256
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
281 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
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 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
284 """ parser.wiki: escape html markup in getText formatted call """
3143
16ae95df840a i18n.getText: fixed some callers that had still 'formatted=' kw args
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3052
diff changeset
285 test = self.request.getText('<escape-me>', wiki=True)
2256
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
286 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
287
691b6a650d94 test_text_moin_wiki: moved to _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 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
289 """ parser.wiki: escape html markup in getText formatted call with link """
3143
16ae95df840a i18n.getText: fixed some callers that had still 'formatted=' kw args
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3052
diff changeset
290 test = self.request.getText('[[<escape-me>]]', wiki=True)
2256
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
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 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
294 """ parser.wiki: escape html markup in getText non formatted call """
3143
16ae95df840a i18n.getText: fixed some callers that had still 'formatted=' kw args
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3052
diff changeset
295 test = self.request.getText('<escape-me>', wiki=False)
2256
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
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 _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
299 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
300 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
301 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
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
691b6a650d94 test_text_moin_wiki: moved to _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 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
305
691b6a650d94 test_text_moin_wiki: moved to _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 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
307 """ 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
308 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
309 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
310
691b6a650d94 test_text_moin_wiki: moved to _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 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
312 """ 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
313 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
314 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
315
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
316 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
317 """ 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
318 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
319 ||<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
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 '''
691b6a650d94 test_text_moin_wiki: moved to _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 self.do(test)
2261
7e04a576e8c7 test_text_moin_wiki: small PEP8 changes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2258
diff changeset
323
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
324 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
325 """ 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
326 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
327 ||<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
328 }}}
691b6a650d94 test_text_moin_wiki: moved to _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 '''
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
330 self.do(test)
2261
7e04a576e8c7 test_text_moin_wiki: small PEP8 changes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2258
diff changeset
331
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
332 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
333 """ 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
334 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
335 # ||<tablewidth="80"> Table ||
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
336 }}}
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
337 '''
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
338 self.do(test)
691b6a650d94 test_text_moin_wiki: moved to _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
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
340 def do(self, test):
6095
465cb6f5c6d7 moin code fixes needed for werkzeug 0.11.11
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5653
diff changeset
341 expected = r'&lt;tablewidth=&quot;80&quot;&gt;'
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
342 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
343 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
344
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
345
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
346 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
347 """ 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
348
691b6a650d94 test_text_moin_wiki: moved to _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 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
350 """ 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
351 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
352 expected = '---' # inside <p>
2624
3d30e923448f wiki parser tests: convert to py.test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2623
diff changeset
353 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
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 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
356 """ 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
357 result = self.parse('----')
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(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
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 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
361 """ 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
362
691b6a650d94 test_text_moin_wiki: moved to _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 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
364 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
365 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
366 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
367
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
368 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
369 """ 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
370 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
371 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
372 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
373
691b6a650d94 test_text_moin_wiki: moved to _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 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
376 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
377 # 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
378 ('----\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
379 ('= 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
380 ('{{{\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
381 ('{{{\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
382 ('|| 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
383 (' * 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
384 (' 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
385 (' 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
386 )
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
387
691b6a650d94 test_text_moin_wiki: moved to _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 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
389 """ 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
390 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
391 %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
392 """
691b6a650d94 test_text_moin_wiki: moved to _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 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
394 # We dont test here formatter white space generation
5653
b82318102f22 fix failing tests in pep8, moin and creole parsers dues to changes in highlight.py
Radomir Dopieralski <moindev@sheep.art.pl>
parents: 5430
diff changeset
395 expected = r'<p.*?>AAA\s*\n*(<span.*?></span>\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
396 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
397 result = self.parse(text % test)
3052
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2778
diff changeset
398 print expected, result
2624
3d30e923448f wiki parser tests: convert to py.test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2623
diff changeset
399 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
400
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
401 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
402 """ 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
403
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
404 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
405 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
406
691b6a650d94 test_text_moin_wiki: moved to _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 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
408 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
409 """
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
410 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
411
691b6a650d94 test_text_moin_wiki: moved to _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 %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
413 """
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
414 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
415 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
416 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
417 result = self.parse(text % test)
3052
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2778
diff changeset
418 print expected, result
2624
3d30e923448f wiki parser tests: convert to py.test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2623
diff changeset
419 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
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 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
422 """ 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
423 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
424
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
425 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
426 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
427
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
428 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
429 """ 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
430 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
431
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
432 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
433 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
434
691b6a650d94 test_text_moin_wiki: moved to _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 def testColorizedPythonParserAndNestingPreBrackets(self):
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
436 """ 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
437 """
3052
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2778
diff changeset
438 raw = """{{{{
2258
9c66c14f6b62 text_moin_wiki: completing nesting for colorized parsers and some tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2256
diff changeset
439 #!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
440 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
441 pattern = re.compile(r'{{{This is some nested text}}}')
3052
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2778
diff changeset
442 }}}}"""
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
443 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
444 output = ''.join(output)
4411
d01b3a866eb6 tests: remove duplicate test, adapt tests to new highlight parser output
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4327
diff changeset
445 assert "{{{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
446
9c66c14f6b62 text_moin_wiki: completing nesting for colorized parsers and some tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2256
diff changeset
447 def testNestingPreBrackets(self):
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
448 """ 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
449 """
3052
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2778
diff changeset
450 raw = """{{{{
2258
9c66c14f6b62 text_moin_wiki: completing nesting for colorized parsers and some tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2256
diff changeset
451 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
452 You can use {{{brackets}}}
3052
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2778
diff changeset
453 }}}}"""
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
454 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
455 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
456 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
457 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
458
9c66c14f6b62 text_moin_wiki: completing nesting for colorized parsers and some tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2256
diff changeset
459 def testTextBeforeNestingPreBrackets(self):
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
460 """ 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
461 """
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 raw = """Example
3052
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2778
diff changeset
463 {{{{
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2778
diff changeset
464 You can use {{{brackets}}}
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2778
diff changeset
465 }}}}"""
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
466 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
467 output = ''.join(output)
5430
c18b36185649 Tests updated to conform with line number anchors in plain text parser blocks.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 4750
diff changeset
468 assert re.search('Example <ul><li style="list-style-type:none"><pre><span class="anchor" id="[^"]*"></span>You can use {{{brackets}}}</pre>', 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
469
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
470 def testManyNestingPreBrackets(self):
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
471 """ 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
472 """
3052
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2778
diff changeset
473 raw = """{{{{
2263
c1682ea7ed8c text_moin_wiki: fixed an other nesting {{{ }}} problem and added a new test
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2262
diff changeset
474 Test {{{brackets}}} and test {{{brackets}}}
3052
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2778
diff changeset
475 }}}}"""
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
476 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
477 output = ''.join(output)
5430
c18b36185649 Tests updated to conform with line number anchors in plain text parser blocks.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 4750
diff changeset
478 expected = '<pre><span class="anchor" id="[^"]*"></span>Test {{{brackets}}} and test {{{brackets}}}'
c18b36185649 Tests updated to conform with line number anchors in plain text parser blocks.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 4750
diff changeset
479 assert re.search(expected, 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
480
2526
860e7bf6c4cc add failing {{{ }}} test
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2516
diff changeset
481 def testMultipleShortPreSections(self):
860e7bf6c4cc add failing {{{ }}} test
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2516
diff changeset
482 """
860e7bf6c4cc add failing {{{ }}} test
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2516
diff changeset
483 tests two single {{{ }}} in one line
860e7bf6c4cc add failing {{{ }}} test
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2516
diff changeset
484 """
2623
5c6d61bf88c5 wiki parser tests: fixed some other broken tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2622
diff changeset
485 raw = 'def {{{ghi}}} jkl {{{mno}}}'
2526
860e7bf6c4cc add failing {{{ }}} test
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2516
diff changeset
486 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
487 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
488 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
489
2371
7de0a5eebf76 first simple test for link markup, fails
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2362
diff changeset
490 class TestLinkingMarkup(ParserTestCase):
2774
9d63b942987a more link/transclusion markup tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2739
diff changeset
491 """ Test wiki link markup """
2371
7de0a5eebf76 first simple test for link markup, fails
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2362
diff changeset
492
7de0a5eebf76 first simple test for link markup, fails
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2362
diff changeset
493 text = 'AAA %s AAA'
7de0a5eebf76 first simple test for link markup, fails
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2362
diff changeset
494 needle = re.compile(text % r'(.+)')
2774
9d63b942987a more link/transclusion markup tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2739
diff changeset
495 _tests = [
2739
9fd4a16a08cc tests: some more wiki parser link markup tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2727
diff changeset
496 # test, expected
4209
7abbc2bb328d Fix tests: script_root in links wrongly expected to be "." (for tests)
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 3244
diff changeset
497 ('SomeNonExistentPage', '<a class="nonexistent" href="/SomeNonExistentPage">SomeNonExistentPage</a>'),
7abbc2bb328d Fix tests: script_root in links wrongly expected to be "." (for tests)
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 3244
diff changeset
498 ('SomeNonExistentPage#anchor', '<a class="nonexistent" href="/SomeNonExistentPage#anchor">SomeNonExistentPage#anchor</a>'),
7abbc2bb328d Fix tests: script_root in links wrongly expected to be "." (for tests)
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 3244
diff changeset
499 ('[[something]]', '<a class="nonexistent" href="/something">something</a>'),
7abbc2bb328d Fix tests: script_root in links wrongly expected to be "." (for tests)
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 3244
diff changeset
500 ('[[some thing]]', '<a class="nonexistent" href="/some%20thing">some thing</a>'),
7abbc2bb328d Fix tests: script_root in links wrongly expected to be "." (for tests)
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 3244
diff changeset
501 ('[[something|some text]]', '<a class="nonexistent" href="/something">some text</a>'),
7abbc2bb328d Fix tests: script_root in links wrongly expected to be "." (for tests)
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 3244
diff changeset
502 ('[[../something]]', '<a class="nonexistent" href="/something">../something</a>'),
7abbc2bb328d Fix tests: script_root in links wrongly expected to be "." (for tests)
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 3244
diff changeset
503 ('[[/something]]', '<a class="nonexistent" href="/%s/something">/something</a>' % PAGENAME),
7abbc2bb328d Fix tests: script_root in links wrongly expected to be "." (for tests)
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 3244
diff changeset
504 ('[[something#anchor]]', '<a class="nonexistent" href="/something#anchor">something#anchor</a>'),
3052
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2778
diff changeset
505 ('MoinMoin:something', '<a class="interwiki" href="http://moinmo.in/something" title="MoinMoin">something</a>'),
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2778
diff changeset
506 ('[[MoinMoin:something|some text]]', '<a class="interwiki" href="http://moinmo.in/something" title="MoinMoin">some text</a>'),
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2778
diff changeset
507 ('[[MoinMoin:with space]]', '<a class="interwiki" href="http://moinmo.in/with%20space" title="MoinMoin">with space</a>'),
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2778
diff changeset
508 ('[[MoinMoin:with space|some text]]', '<a class="interwiki" href="http://moinmo.in/with%20space" title="MoinMoin">some text</a>'),
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2778
diff changeset
509 # no interwiki:
4209
7abbc2bb328d Fix tests: script_root in links wrongly expected to be "." (for tests)
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 3244
diff changeset
510 ('[[ABC:n]]', '<a class="nonexistent" href="/ABC%3An">ABC:n</a>'), # finnish/swedish abbreviations / possessive
3052
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2778
diff changeset
511 ('ABC:n', 'ABC:n'), # finnish/swedish abbreviations / possessive
1d3e65884337 copy moin wiki parser and its tests from 1.6 branch (cs 2558:3e3a549b49f0), keep _heading_repl from 1.7, update interwiki map to make tests happy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2778
diff changeset
512 ('lowercase:nointerwiki', 'lowercase:nointerwiki'),
2739
9fd4a16a08cc tests: some more wiki parser link markup tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2727
diff changeset
513 ('[[http://google.com/|google]]', '<a class="http" href="http://google.com/">google</a>'),
2774
9d63b942987a more link/transclusion markup tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2739
diff changeset
514 ]
2371
7de0a5eebf76 first simple test for link markup, fails
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2362
diff changeset
515
2774
9d63b942987a more link/transclusion markup tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2739
diff changeset
516 def testLinkFormating(self):
9d63b942987a more link/transclusion markup tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2739
diff changeset
517 """ parser.wiki: link formating """
2371
7de0a5eebf76 first simple test for link markup, fails
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2362
diff changeset
518 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
519 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
520 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
521 assert result == expected
2774
9d63b942987a more link/transclusion markup tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2739
diff changeset
522
9d63b942987a more link/transclusion markup tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2739
diff changeset
523 def testLinkAttachment(self):
9d63b942987a more link/transclusion markup tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2739
diff changeset
524 html = self.parse("[[attachment:some file.txt]]")
9d63b942987a more link/transclusion markup tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2739
diff changeset
525 assert '<a ' in html
9d63b942987a more link/transclusion markup tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2739
diff changeset
526 assert 'href="' in html
9d63b942987a more link/transclusion markup tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2739
diff changeset
527 assert 'class="attachment nonexistent"' in html
9d63b942987a more link/transclusion markup tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2739
diff changeset
528 assert 'action=AttachFile' in html
9d63b942987a more link/transclusion markup tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2739
diff changeset
529 assert 'some+file.txt' in html
9d63b942987a more link/transclusion markup tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2739
diff changeset
530
9d63b942987a more link/transclusion markup tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2739
diff changeset
531 def testLinkAttachmentImage(self):
9d63b942987a more link/transclusion markup tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2739
diff changeset
532 html = self.parse("[[attachment:some file.png]]")
9d63b942987a more link/transclusion markup tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2739
diff changeset
533 assert '<a ' in html # must create a link
9d63b942987a more link/transclusion markup tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2739
diff changeset
534 assert 'href="' in html
9d63b942987a more link/transclusion markup tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2739
diff changeset
535 assert 'class="attachment nonexistent"' in html
9d63b942987a more link/transclusion markup tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2739
diff changeset
536 assert 'action=AttachFile' in html
9d63b942987a more link/transclusion markup tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2739
diff changeset
537 assert 'some+file.png' in html
9d63b942987a more link/transclusion markup tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2739
diff changeset
538
9d63b942987a more link/transclusion markup tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2739
diff changeset
539
9d63b942987a more link/transclusion markup tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2739
diff changeset
540 class TestTransclusionMarkup(ParserTestCase):
9d63b942987a more link/transclusion markup tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2739
diff changeset
541 """ Test wiki markup """
9d63b942987a more link/transclusion markup tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2739
diff changeset
542
9d63b942987a more link/transclusion markup tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2739
diff changeset
543 text = 'AAA %s AAA'
9d63b942987a more link/transclusion markup tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2739
diff changeset
544 needle = re.compile(text % r'(.+)')
9d63b942987a more link/transclusion markup tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2739
diff changeset
545 _tests = [
9d63b942987a more link/transclusion markup tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2739
diff changeset
546 # test, expected
9d63b942987a more link/transclusion markup tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2739
diff changeset
547 ('{{http://moinmo.in/wiki/common/moinmoin.png}}', '<img alt="http://moinmo.in/wiki/common/moinmoin.png" class="external_image" src="http://moinmo.in/wiki/common/moinmoin.png" title="http://moinmo.in/wiki/common/moinmoin.png" />'),
9d63b942987a more link/transclusion markup tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2739
diff changeset
548 ('{{http://moinmo.in/wiki/common/moinmoin.png|moin logo}}', '<img alt="moin logo" class="external_image" src="http://moinmo.in/wiki/common/moinmoin.png" title="moin logo" />'),
9d63b942987a more link/transclusion markup tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2739
diff changeset
549 ]
9d63b942987a more link/transclusion markup tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2739
diff changeset
550
9d63b942987a more link/transclusion markup tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2739
diff changeset
551 def testTransclusionFormating(self):
9d63b942987a more link/transclusion markup tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2739
diff changeset
552 """ parser.wiki: transclusion formating """
9d63b942987a more link/transclusion markup tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2739
diff changeset
553 for test, expected in self._tests:
9d63b942987a more link/transclusion markup tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2739
diff changeset
554 html = self.parse(self.text % test)
9d63b942987a more link/transclusion markup tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2739
diff changeset
555 result = self.needle.search(html).group(1)
9d63b942987a more link/transclusion markup tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2739
diff changeset
556 assert result == expected
2378
a7f4b02f5fdb fix the quoting mess
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2375
diff changeset
557
3221
e9ab91483e02 wiki parser: add new test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3217
diff changeset
558 class TestMacrosInOneLine(ParserTestCase):
e9ab91483e02 wiki parser: add new test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3217
diff changeset
559 """ Test macro formatting """
e9ab91483e02 wiki parser: add new test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3217
diff changeset
560 text = 'AAA %s AAA'
e9ab91483e02 wiki parser: add new test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3217
diff changeset
561 needle = re.compile(text % r'(.+)')
e9ab91483e02 wiki parser: add new test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3217
diff changeset
562 _tests = (
e9ab91483e02 wiki parser: add new test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3217
diff changeset
563 # test expected
e9ab91483e02 wiki parser: add new test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3217
diff changeset
564 (u'<<Verbatim(A)>><<Verbatim(a)>>', 'Aa'),
e9ab91483e02 wiki parser: add new test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3217
diff changeset
565 (u'<<Verbatim(A)>> <<Verbatim(a)>>', 'A a'),
e9ab91483e02 wiki parser: add new test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3217
diff changeset
566 )
e9ab91483e02 wiki parser: add new test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3217
diff changeset
567
e9ab91483e02 wiki parser: add new test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3217
diff changeset
568 def testMultipleMacrosInOneLine(self):
e9ab91483e02 wiki parser: add new test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3217
diff changeset
569 """ parser.wiki: multiple macros in one line and no linebreak """
e9ab91483e02 wiki parser: add new test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3217
diff changeset
570 for test, expected in self._tests:
e9ab91483e02 wiki parser: add new test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3217
diff changeset
571 html = self.parse(self.text % test)
e9ab91483e02 wiki parser: add new test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3217
diff changeset
572 result = self.needle.search(html).group(1)
e9ab91483e02 wiki parser: add new test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3217
diff changeset
573 assert result == expected
e9ab91483e02 wiki parser: add new test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3217
diff changeset
574
2448
c9949c55ff5e add coverage_modules attribute for coverage testing
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2378
diff changeset
575
c9949c55ff5e add coverage_modules attribute for coverage testing
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2378
diff changeset
576 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
577