annotate MoinMoin/parser/_tests/test_text_moin_wiki.py @ 2375:f9b0d11a6569

use assert in linking test
author Johannes Berg <johannes AT sipsolutions DOT net>
date Thu, 12 Jul 2007 14:42:19 +0200
parents 7e7560f2cddd
children a7f4b02f5fdb
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 unittest # LEGACY UNITTEST, PLEASE DO NOT IMPORT unittest IN NEW TESTS, PLEASE CONSULT THE py.test DOCS
691b6a650d94 test_text_moin_wiki: moved to _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 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
14 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
15
691b6a650d94 test_text_moin_wiki: moved to _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 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
17
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
18 from MoinMoin.Page import Page
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
19 from MoinMoin.parser.text_moin_wiki import Parser
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
20
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
21
691b6a650d94 test_text_moin_wiki: moved to _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 class ParserTestCase(unittest.TestCase):
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
23 """ Helper class that provide a parsing method """
2261
7e04a576e8c7 test_text_moin_wiki: small PEP8 changes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2258
diff changeset
24
2256
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
25 def parse(self, body):
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
26 """Parse body and return html
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
27
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
28 Create a page with body, then parse it and format using html formatter
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
29 """
691b6a650d94 test_text_moin_wiki: moved to _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 assert body is not None
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
31 self.request.reset()
691b6a650d94 test_text_moin_wiki: moved to _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 page = Page(self.request, 'ThisPageDoesNotExistsAndWillNeverBeReally')
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
33 page.set_raw_body(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
34 from MoinMoin.formatter.text_html import 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
35 page.formatter = Formatter(self.request)
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
36 self.request.formatter = page.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
37 page.formatter.setPage(page)
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
38 page.hilite_re = None
2261
7e04a576e8c7 test_text_moin_wiki: small PEP8 changes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2258
diff changeset
39
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
40 output = 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
41 saved_write = self.request.write
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
42 self.request.write = output.write
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
43 try:
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
44 Parser(body, self.request).format(page.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
45 finally:
691b6a650d94 test_text_moin_wiki: moved to _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 self.request.write = saved_write
691b6a650d94 test_text_moin_wiki: moved to _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 return output.getvalue()
691b6a650d94 test_text_moin_wiki: moved to _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
691b6a650d94 test_text_moin_wiki: moved to _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
691b6a650d94 test_text_moin_wiki: moved to _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 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
51 """ 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
52
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
53 All tests ignoring white space in output
691b6a650d94 test_text_moin_wiki: moved to _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
691b6a650d94 test_text_moin_wiki: moved to _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 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
57 """ 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
58 py.test.skip("Broken because of line numbers")
691b6a650d94 test_text_moin_wiki: moved to _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 result = self.parse('First')
691b6a650d94 test_text_moin_wiki: moved to _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 expected = re.compile(r'<p>\s*First\s*</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
61 self.assert_(expected.search(result),
691b6a650d94 test_text_moin_wiki: moved to _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 '"%s" not in "%s"' % (expected.pattern, result))
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
63
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
64 def 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
65 """ 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
66 py.test.skip("Broken because of line numbers")
691b6a650d94 test_text_moin_wiki: moved to _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 result = self.parse('First\n\nSecond')
691b6a650d94 test_text_moin_wiki: moved to _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 expected = re.compile(r'<p>\s*Second\s*</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
69 self.assert_(expected.search(result),
691b6a650d94 test_text_moin_wiki: moved to _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 '"%s" not in "%s"' % (expected.pattern, result))
2261
7e04a576e8c7 test_text_moin_wiki: small PEP8 changes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2258
diff changeset
71
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
72 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
73 """ 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
74 py.test.skip("Broken because of line numbers")
691b6a650d94 test_text_moin_wiki: moved to _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
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
76 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
77 '----\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
78 '[[en]]\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
79 '|| 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
80 '= 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
81 '== 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
82 '=== 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
83 '==== 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
84 '===== heading 5 =====\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
85 )
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
86 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
87 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
88 result = self.parse(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
89 expected = re.compile(r'<p.*?>\s*Paragraph\s*</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
90 self.assert_(expected.search(result),
691b6a650d94 test_text_moin_wiki: moved to _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 '"%s" not in "%s"' % (expected.pattern, result))
691b6a650d94 test_text_moin_wiki: moved to _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
691b6a650d94 test_text_moin_wiki: moved to _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
691b6a650d94 test_text_moin_wiki: moved to _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 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
95 """ 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
96
691b6a650d94 test_text_moin_wiki: moved to _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 def setUp(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
98 """ Require show_section_numbers = 0 to workaround counter
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
99 global state saved in request.
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
100 """
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
101 self.config = self.TestConfig(show_section_numbers=0)
2261
7e04a576e8c7 test_text_moin_wiki: small PEP8 changes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2258
diff changeset
102
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
103 def tearDown(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
104 del self.config
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
105
691b6a650d94 test_text_moin_wiki: moved to _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 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
107 """ 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
108
691b6a650d94 test_text_moin_wiki: moved to _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 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
110
691b6a650d94 test_text_moin_wiki: moved to _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 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
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 py.test.skip("Broken because of line numbers")
691b6a650d94 test_text_moin_wiki: moved to _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 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
115 '= 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
116 '= 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
117 '= 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
118 )
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
119 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
120 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
121 result = self.parse(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
122 self.assertEqual(result, 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
123 'Expected "%(expected)s" but got "%(result)s"' % locals())
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
124
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
125
691b6a650d94 test_text_moin_wiki: moved to _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 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
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 def setUp(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
129 """ Require show_section_numbers = 0 to workaround counter
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
130 global state saved in request.
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
131 """
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
132 self.config = self.TestConfig(show_section_numbers=0)
2261
7e04a576e8c7 test_text_moin_wiki: small PEP8 changes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2258
diff changeset
133
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
134 def tearDown(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
135 del self.config
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
136
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
137 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
138 """ 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
139
2256
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
140 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
141
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
142 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
143 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
144 """
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
145 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
146 [[TableOfContents]]
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
147 = 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
148 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
149 """
691b6a650d94 test_text_moin_wiki: moved to _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 withWhitespace = """
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
151 [[TableOfContents]]
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
152 = 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
153 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
154 """
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
155 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
156 result = self.parse(withWhitespace)
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
157 self.assertEqual(result, 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
158 'Expected "%(expected)s" but got "%(result)s"' % locals())
2261
7e04a576e8c7 test_text_moin_wiki: small PEP8 changes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2258
diff changeset
159
2256
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
160
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
161 class TestDateTimeMacro(ParserTestCase):
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
162 """ Test DateTime macro
2261
7e04a576e8c7 test_text_moin_wiki: small PEP8 changes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2258
diff changeset
163
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
164 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
165 * 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
166 * 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
167 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
168 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
169 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
170 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
171 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
172 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
173
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
174 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
175 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
176 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
177 """
2261
7e04a576e8c7 test_text_moin_wiki: small PEP8 changes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2258
diff changeset
178
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
179 text = 'AAA %s AAA'
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
180 needle = re.compile(text % r'(.+)')
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
181 _tests = (
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
182 # test expected
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
183 ('[[DateTime(259200)]]', '1970-01-04 00:00:00'),
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
184 ('[[DateTime(2003-03-03T03:03:03)]]', '2003-03-03 03:03:03'),
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
185 ('[[DateTime(2000-01-01T00:00:00Z)]]', '2000-01-01 00:00:00'), # works for Europe/Vilnius
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
186 ('[[Date(2002-02-02T01:02:03Z)]]', '2002-02-02'),
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
187 ('[[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
188 )
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
189
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
190 def setUp(self):
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
191 """ Require default date and time format config values """
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
192 self.config = self.TestConfig(defaults=('date_fmt', 'datetime_fmt'))
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
193
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
194 def tearDown(self):
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
195 del self.config
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
196
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
197 def testDateTimeMacro(self):
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
198 """ parser.wiki: DateTime macro """
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
199 note = """
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
200
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
201 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
202 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
203
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
204 It can also be related to TZ changes a country historically made.
953a0e4e3dac tests: document some DateTime timezone related test failure we can't easily fix for some special cases
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2286
diff changeset
205 """
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
206
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
207 for test, expected in self._tests:
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
208 html = self.parse(self.text % test)
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
209 result = self.needle.search(html).group(1)
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
210 self.assertEqual(result, expected,
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
211 'Expected "%(expected)s" but got "%(result)s"; %(note)s' % locals())
2261
7e04a576e8c7 test_text_moin_wiki: small PEP8 changes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2258
diff changeset
212
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
213
691b6a650d94 test_text_moin_wiki: moved to _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 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
215 """ Test wiki markup """
2261
7e04a576e8c7 test_text_moin_wiki: small PEP8 changes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2258
diff changeset
216
2256
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
217 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
218 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
219 _tests = (
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
220 # 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
221 ('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
222 ("''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
223 ("'''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
224 ("__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
225 ("'''''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
226 ("'''''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
227 ("'''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
228 ("''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
229 )
2261
7e04a576e8c7 test_text_moin_wiki: small PEP8 changes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2258
diff changeset
230
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
231 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
232 """ 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
233 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
234 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
235 result = self.needle.search(html).group(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
236 self.assertEqual(result, 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
237 'Expected "%(expected)s" but got "%(result)s"' % locals())
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
238
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
239
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
240 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
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 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
243 """ parser.wiki: close open inline tag when block close """
691b6a650d94 test_text_moin_wiki: moved to _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 py.test.skip("Broken because of line numbers")
691b6a650d94 test_text_moin_wiki: moved to _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 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
246 # 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
247 ("text'''text\n", r"<p>text<strong>text\s*</strong></p>"),
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
248 ("text''text\n", r"<p>text<em>text\s*</em></p>"),
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
249 ("text__text\n", r"<p>text<span class=\"u\">text\s*</span></p>"),
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
250 ("text ''em '''em strong __em strong underline",
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
251 r"text <em>em <strong>em strong <span class=\"u\">em strong underline"
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
252 r"\s*</span></strong></em></p>"),
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
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 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
255 needle = re.compile(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
256 result = self.parse(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 self.assert_(needle.search(result),
691b6a650d94 test_text_moin_wiki: moved to _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 'Expected "%(expected)s" but got "%(result)s"' % locals())
691b6a650d94 test_text_moin_wiki: moved to _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
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
261 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
262 """
691b6a650d94 test_text_moin_wiki: moved to _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 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
264 """
2261
7e04a576e8c7 test_text_moin_wiki: small PEP8 changes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2258
diff changeset
265
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
266 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
267 """ 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
268
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
269 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
270 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
271 needle = re.compile(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
272 result = self.parse(test)
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
273 self.assert_(needle.search(result),
691b6a650d94 test_text_moin_wiki: moved to _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 'Expected "%(expected)s" but got "%(result)s"' % locals())
2261
7e04a576e8c7 test_text_moin_wiki: small PEP8 changes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2258
diff changeset
275
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
276
691b6a650d94 test_text_moin_wiki: moved to _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 class TestEscapeHTML(ParserTestCase):
2261
7e04a576e8c7 test_text_moin_wiki: small PEP8 changes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2258
diff changeset
278
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
279 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
280 """ 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
281 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
282 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
283
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
284 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
285 """ 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
286 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
287 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
288
691b6a650d94 test_text_moin_wiki: moved to _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 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
290 """ 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
291 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 <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
293 }}}
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
294 '''
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
295 self._test(test)
2261
7e04a576e8c7 test_text_moin_wiki: small PEP8 changes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2258
diff changeset
296
2256
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
297 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
298 """ 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
299 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
300 <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
301 }}}
691b6a650d94 test_text_moin_wiki: moved to _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 self._test(test)
2261
7e04a576e8c7 test_text_moin_wiki: small PEP8 changes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2258
diff changeset
304
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
305 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
306 """ 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
307 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
308 #<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
309 }}}
691b6a650d94 test_text_moin_wiki: moved to _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 self._test(test)
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
312
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
313 def 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
314 """ parser.wiki: escape html markup in GetText macro """
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
315 test = "text [[GetText(<escape-me>)]] text"
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
316 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
317
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
318 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
319 """ parser.wiki: escape html markup in getText formatted call """
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
320 test = self.request.getText('<escape-me>', formatted=1)
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
321 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
322
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
323 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
324 """ parser.wiki: escape html markup in getText formatted call with link """
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
325 test = self.request.getText('["<escape-me>"]', formatted=1)
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
326 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
327
691b6a650d94 test_text_moin_wiki: moved to _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 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
329 """ parser.wiki: escape html markup in getText non formatted call """
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
330 test = self.request.getText('<escape-me>', formatted=0)
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
331 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
332
691b6a650d94 test_text_moin_wiki: moved to _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 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
334 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
335 result = self.parse(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
336 self.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
337 'Expected "%(expected)s" but got "%(result)s"' % locals())
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
338
691b6a650d94 test_text_moin_wiki: moved to _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 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
341
691b6a650d94 test_text_moin_wiki: moved to _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 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
343 """ 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
344 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
345 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
346
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
347 def 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
348 """ 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
349 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
350 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
351
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
352 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
353 """ 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
354 test = '''{{{
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
355 ||<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
356 }}}
691b6a650d94 test_text_moin_wiki: moved to _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 '''
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
358 self.do(test)
2261
7e04a576e8c7 test_text_moin_wiki: small PEP8 changes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2258
diff changeset
359
2256
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
360 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
361 """ 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
362 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
363 ||<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
364 }}}
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
365 '''
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
366 self.do(test)
2261
7e04a576e8c7 test_text_moin_wiki: small PEP8 changes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2258
diff changeset
367
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
368 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
369 """ 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
370 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
371 # ||<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
372 }}}
691b6a650d94 test_text_moin_wiki: moved to _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 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
375
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
376 def do(self, test):
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
377 expected = r'&lt;tablewidth="80"&gt;'
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
378 result = self.parse(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
379 self.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
380 'Expected "%(expected)s" but got "%(result)s"' % locals())
2256
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
381
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
382
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
383 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
384 """ 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
385
691b6a650d94 test_text_moin_wiki: moved to _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 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
387 """ 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
388 py.test.skip("Broken because of line numbers")
691b6a650d94 test_text_moin_wiki: moved to _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 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
390 expected = '---' # inside <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
391 self.assert_(expected in result,
691b6a650d94 test_text_moin_wiki: moved to _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 'Expected "%(expected)s" but got "%(result)s"' % locals())
691b6a650d94 test_text_moin_wiki: moved to _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
691b6a650d94 test_text_moin_wiki: moved to _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 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
395 """ 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
396 py.test.skip("Broken because of line numbers")
691b6a650d94 test_text_moin_wiki: moved to _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('----')
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
398 expected = '<hr>'
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
399 self.assert_(expected in result,
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
400 'Expected "%(expected)s" but got "%(result)s"' % locals())
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
401
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
402 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
403 """ 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
404 py.test.skip("Broken because of line numbers")
691b6a650d94 test_text_moin_wiki: moved to _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
691b6a650d94 test_text_moin_wiki: moved to _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 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
407 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
408 result = self.parse(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
409 expected = '<hr class="hr%d">' % (size - 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
410 self.assert_(expected in result,
691b6a650d94 test_text_moin_wiki: moved to _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 'Expected "%(expected)s" but got "%(result)s"' % locals())
691b6a650d94 test_text_moin_wiki: moved to _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
691b6a650d94 test_text_moin_wiki: moved to _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 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
414 """ parser.wiki: ------------ long rule shortened to hr6 """
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
415 py.test.skip("Broken because of line numbers")
2261
7e04a576e8c7 test_text_moin_wiki: small PEP8 changes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2258
diff changeset
416 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
417 result = self.parse(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
418 expected = '<hr class="hr6">'
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
419 self.assert_(expected in result,
691b6a650d94 test_text_moin_wiki: moved to _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 'Expected "%(expected)s" but got "%(result)s"' % locals())
691b6a650d94 test_text_moin_wiki: moved to _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
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
422
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
423 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
424 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
425 # 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
426 ('----\n', '<hr'),
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
427 ('= Heading =\n', '<h2'),
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
428 ('{{{\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
429 ('{{{\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
430 ('|| 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
431 (' * 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
432 (' 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
433 (' 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
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
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
436 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
437 """ 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
438 py.test.skip("Broken because of line numbers")
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
439 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
440 %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
441 """
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
442 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
443 # We dont test here formatter white space generation
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
444 expected = r'<p>AAA\s*</p>\n+%s' % blockstart
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
445 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
446 result = self.parse(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
447 match = needle.search(result)
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
448 self.assert_(match is not None,
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
449 'Expected "%(expected)s" but got "%(result)s"' % locals())
2261
7e04a576e8c7 test_text_moin_wiki: small PEP8 changes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2258
diff changeset
450
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
451 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
452 """ 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
453
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
454 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
455 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
456
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
457 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
458 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
459 """
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
460 py.test.skip("Broken because of line numbers")
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
461 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
462
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
463 %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
464 """
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
465 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
466 expected = r'<p>AAA\s*</p>\n+%s' % blockstart
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
467 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
468 result = self.parse(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
469 match = needle.search(result)
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
470 self.assert_(match is not None,
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
471 'Expected "%(expected)s" but got "%(result)s"' % locals())
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
472
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
473 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
474 """ parser.wiki: tests url after 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
475 cases = ('some text {{{some block text\n}}} and a URL http://moinmo.in/',
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
476 'some text {{{some block text\n}}} and a WikiName')
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
477
2261
7e04a576e8c7 test_text_moin_wiki: small PEP8 changes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2258
diff changeset
478 for case in cases:
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
479 result = self.parse(case).strip()
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
480 match = result.endswith('</a>')
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
481 expected = True
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
482 self.assert_(match is True,
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
483 'Expected "%(expected)s" but got "%(result)s"' % locals())
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
484
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
485 def testColorizedPythonParserAndNestingPreBrackets(self):
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
486 """ 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
487 """
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
488
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
489 raw = """{{{
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
490 #!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
491 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
492 pattern = re.compile(r'{{{This is some nested text}}}')}}}"""
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
493 output = self.parse(raw)
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
494 output = ''.join(output)
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
495 result = "r'{{{This is some nested text}}}'" in output
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
496 expected = True
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
497
691b6a650d94 test_text_moin_wiki: moved to _tests/parser, renamed from test_parser_text_moin_wiki, added test for colorized
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
498 assert expected == result
2261
7e04a576e8c7 test_text_moin_wiki: small PEP8 changes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2258
diff changeset
499
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
500 def testColorizedPythonParserAndNestingPreBracketsWithLinebreak(self):
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
501 """ tests nested {{{ }}} for the python colorized parser
2258
9c66c14f6b62 text_moin_wiki: completing nesting for colorized parsers and some tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2256
diff changeset
502 """
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
503
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
504 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
505 #!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
506 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
507 pattern = re.compile(r'{{{This is some nested text}}}')
9c66c14f6b62 text_moin_wiki: completing nesting for colorized parsers and some tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2256
diff changeset
508 }}}"""
9c66c14f6b62 text_moin_wiki: completing nesting for colorized parsers and some tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2256
diff changeset
509 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
510 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
511 print 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
512 result = "r'{{{This is some nested text}}}'" in 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
513 expected = True
9c66c14f6b62 text_moin_wiki: completing nesting for colorized parsers and some tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2256
diff changeset
514
9c66c14f6b62 text_moin_wiki: completing nesting for colorized parsers and some tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2256
diff changeset
515 assert expected == result
9c66c14f6b62 text_moin_wiki: completing nesting for colorized parsers and some tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2256
diff changeset
516
9c66c14f6b62 text_moin_wiki: completing nesting for colorized parsers and some tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2256
diff changeset
517 def testNestingPreBrackets(self):
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
518 """ 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
519 """
9c66c14f6b62 text_moin_wiki: completing nesting for colorized parsers and some tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2256
diff changeset
520
9c66c14f6b62 text_moin_wiki: completing nesting for colorized parsers and some tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2256
diff changeset
521 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
522 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
523 You can use {{{brackets}}}}}}"""
9c66c14f6b62 text_moin_wiki: completing nesting for colorized parsers and some tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2256
diff changeset
524 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
525 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
526 result = 'You can use {{{brackets}}}' in 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
527 expected = True
9c66c14f6b62 text_moin_wiki: completing nesting for colorized parsers and some tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2256
diff changeset
528
9c66c14f6b62 text_moin_wiki: completing nesting for colorized parsers and some tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2256
diff changeset
529 assert expected == result
2261
7e04a576e8c7 test_text_moin_wiki: small PEP8 changes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2258
diff changeset
530
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
531 def testNestingPreBracketsWithLinebreak(self):
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
532 """ 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
533 """
9c66c14f6b62 text_moin_wiki: completing nesting for colorized parsers and some tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2256
diff changeset
534
9c66c14f6b62 text_moin_wiki: completing nesting for colorized parsers and some tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2256
diff changeset
535 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
536 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
537 You can use {{{brackets}}}
9c66c14f6b62 text_moin_wiki: completing nesting for colorized parsers and some tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2256
diff changeset
538 }}}"""
9c66c14f6b62 text_moin_wiki: completing nesting for colorized parsers and some tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2256
diff changeset
539 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
540 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
541 print 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
542 result = 'You can use {{{brackets}}}' in 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
543 expected = True
9c66c14f6b62 text_moin_wiki: completing nesting for colorized parsers and some tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2256
diff changeset
544
9c66c14f6b62 text_moin_wiki: completing nesting for colorized parsers and some tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2256
diff changeset
545 assert expected == result
9c66c14f6b62 text_moin_wiki: completing nesting for colorized parsers and some tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2256
diff changeset
546
9c66c14f6b62 text_moin_wiki: completing nesting for colorized parsers and some tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2256
diff changeset
547 def testTextBeforeNestingPreBrackets(self):
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
548 """ 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
549 """
9c66c14f6b62 text_moin_wiki: completing nesting for colorized parsers and some tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2256
diff changeset
550
9c66c14f6b62 text_moin_wiki: completing nesting for colorized parsers and some tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2256
diff changeset
551 raw = """Example
9c66c14f6b62 text_moin_wiki: completing nesting for colorized parsers and some tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2256
diff changeset
552 {{{
9c66c14f6b62 text_moin_wiki: completing nesting for colorized parsers and some tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2256
diff changeset
553 You can use {{{brackets}}}}}}"""
9c66c14f6b62 text_moin_wiki: completing nesting for colorized parsers and some tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2256
diff changeset
554 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
555 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
556 result = 'Example <span class="anchor" id="line-0"></span><ul><li style="list-style-type:none"><span class="anchor" id="line-0"></span><pre>You can use {{{brackets}}}</pre>' in 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
557 expected = True
9c66c14f6b62 text_moin_wiki: completing nesting for colorized parsers and some tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2256
diff changeset
558
2262
ec8d3c66ad0c test_text_moin_wiki: typo fixed
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2261
diff changeset
559 assert expected == result
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
560
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
561 def testManyNestingPreBrackets(self):
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2269
diff changeset
562 """ 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
563 """
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
564
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
565 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
566 Test {{{brackets}}} and test {{{brackets}}}
c1682ea7ed8c text_moin_wiki: fixed an other nesting {{{ }}} problem and added a new test
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2262
diff changeset
567 }}}"""
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
568 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
569 output = ''.join(output)
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
570 result = '</span><p><pre>Test {{{brackets}}} and test {{{brackets}}}' in output
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
571 expected = True
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
572
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
573 assert expected == result
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
574
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
575
2371
7de0a5eebf76 first simple test for link markup, fails
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2362
diff changeset
576 class TestLinkingMarkup(ParserTestCase):
7de0a5eebf76 first simple test for link markup, fails
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2362
diff changeset
577 """ Test wiki markup """
7de0a5eebf76 first simple test for link markup, fails
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2362
diff changeset
578
7de0a5eebf76 first simple test for link markup, fails
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2362
diff changeset
579 text = 'AAA %s AAA'
7de0a5eebf76 first simple test for link markup, fails
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2362
diff changeset
580 needle = re.compile(text % r'(.+)')
7de0a5eebf76 first simple test for link markup, fails
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2362
diff changeset
581 _tests = (
2372
704c1051e73f more link tests as I expect things to behave
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2371
diff changeset
582 # test, expected
704c1051e73f more link tests as I expect things to behave
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2371
diff changeset
583 ('["something"]', '<a class="nonexistent" href="./something">something</a>'),
704c1051e73f more link tests as I expect things to behave
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2371
diff changeset
584 ("['something']", "['something']"),
704c1051e73f more link tests as I expect things to behave
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2371
diff changeset
585 ('MoinMoin:"something"', '<a class="interwiki" href="http://moinmoin.wikiwikiweb.de/something" title="MoinMoin">something</a>'),
2373
7e7560f2cddd more tests for linking
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2372
diff changeset
586 ('MoinMoin:"with space"', '<a class="interwiki" href="http://moinmoin.wikiwikiweb.de/with%20space" title="MoinMoin">with space</a>'),
7e7560f2cddd more tests for linking
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2372
diff changeset
587 ('RFC:"1 2 3"', '<a class="interwiki" href="http://www.ietf.org/rfc/rfc1%202%203" title="RFC">1 2 3</a>'),
7e7560f2cddd more tests for linking
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2372
diff changeset
588 ("RFC:'something else'", "RFC:'something else'"),
2371
7de0a5eebf76 first simple test for link markup, fails
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2362
diff changeset
589 )
7de0a5eebf76 first simple test for link markup, fails
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2362
diff changeset
590
7de0a5eebf76 first simple test for link markup, fails
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2362
diff changeset
591 def testTextFormating(self):
7de0a5eebf76 first simple test for link markup, fails
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2362
diff changeset
592 """ parser.wiki: text formating """
7de0a5eebf76 first simple test for link markup, fails
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2362
diff changeset
593 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
594 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
595 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
596 assert result == expected