annotate tests/test_parser.py @ 2491:c7b397a38422 default tip

Make it work with newer pygments
author Radomir Dopieralski <sheep-devel@sheep.art.pl>
date Sun, 10 Mar 2019 19:33:33 +0100
parents c022854d3895
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
431
079da4340a13 add the tests
sheep@ghostwheel
parents:
diff changeset
1 #!/usr/bin/python
079da4340a13 add the tests
sheep@ghostwheel
parents:
diff changeset
2 # -*- coding: utf-8 -*-
079da4340a13 add the tests
sheep@ghostwheel
parents:
diff changeset
3
771
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
4
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
5 from lxml.doctestcompare import LHTMLOutputChecker
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
6 import doctest
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
7 import werkzeug
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
8
431
079da4340a13 add the tests
sheep@ghostwheel
parents:
diff changeset
9 import hatta
079da4340a13 add the tests
sheep@ghostwheel
parents:
diff changeset
10
771
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
11
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
12 class HTML(object):
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
13 """
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
14 A class wrapping HTML for better comparison and nicer
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
15 error reporting.
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
16 """
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
17 def __init__(self, text):
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
18 self.text = text
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
19 self.example = doctest.Example('', self.text)
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
20 self.checker = LHTMLOutputChecker()
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
21 self.flags = doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
22 self.print_diff = True
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
23
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
24 def compare(self, other, expect_eq):
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
25 if isinstance(other, HTML):
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
26 text = other.text
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
27 else:
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
28 text = other
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
29 eq = self.checker.check_output(self.text, text, self.flags)
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
30 if self.print_diff and eq != expect_eq:
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
31 print self.checker.output_difference(self.example, text, self.flags)
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
32 # Only output diff once per HTML object.
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
33 self.print_diff = False
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
34 return eq
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
35
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
36 def __eq__(self, other):
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
37 return self.compare(other, True)
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
38
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
39 def __ne__(self, other):
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
40 return self.compare(other, False)
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
41
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
42 def __str__(self):
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
43 return str(self.text)
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
44
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
45 def __unicode__(self):
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
46 return unicode(self.text)
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
47
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
48 def link(addr, label, class_=None, image=None, lineno=0):
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
49 href = werkzeug.escape(addr, quote=True)
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
50 text = image or werkzeug.escape(label or addr)
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
51 return u'<a href="%s">%s</a>' % (href, text)
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
52
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
53 def img(addr, label, class_=None, image=None):
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
54 href = werkzeug.escape(addr, quote=True)
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
55 text = image or werkzeug.escape(label or addr, quote=True)
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
56 return u'<img src="%s" alt="%s">' % (href, text)
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
57
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
58 def hgh(text, mime=None, syntax=None, line_no=0):
2241
d0a2410decdf Split off errors, WikiPage and WikiParser.
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 771
diff changeset
59 class DummyPage(hatta.page.WikiPageColorText):
771
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
60 def __init__(self):
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
61 self.request = self
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
62 self.request.print_highlight_styles = None
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
63 return DummyPage().highlight(text, mime, syntax, line_no)
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
64
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
65 def parse(text):
2486
c022854d3895 Use .splitlines() for markup tests
Sam Toyer <sam@qxcv.net>
parents: 2485
diff changeset
66 lines = text.splitlines(True)
2241
d0a2410decdf Split off errors, WikiPage and WikiParser.
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 771
diff changeset
67 return HTML(u''.join(hatta.parser.WikiParser(lines, link, img, hgh)))
771
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
68
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
69 def wiki_parse(text):
2486
c022854d3895 Use .splitlines() for markup tests
Sam Toyer <sam@qxcv.net>
parents: 2485
diff changeset
70 lines = text.splitlines(True)
2241
d0a2410decdf Split off errors, WikiPage and WikiParser.
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 771
diff changeset
71 return HTML(u''.join(hatta.parser.WikiWikiParser(lines, link, img, hgh)))
771
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
72
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
73
431
079da4340a13 add the tests
sheep@ghostwheel
parents:
diff changeset
74 class TestParser(object):
079da4340a13 add the tests
sheep@ghostwheel
parents:
diff changeset
75 def test_extract_links(self):
079da4340a13 add the tests
sheep@ghostwheel
parents:
diff changeset
76 text = """[[one link]] some
079da4340a13 add the tests
sheep@ghostwheel
parents:
diff changeset
77 text [[another|link]] more
079da4340a13 add the tests
sheep@ghostwheel
parents:
diff changeset
78 text [[link]]"""
2241
d0a2410decdf Split off errors, WikiPage and WikiParser.
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 771
diff changeset
79 links = list(hatta.parser.WikiParser.extract_links(text))
431
079da4340a13 add the tests
sheep@ghostwheel
parents:
diff changeset
80 assert links == [
079da4340a13 add the tests
sheep@ghostwheel
parents:
diff changeset
81 ('one link', 'one link'),
079da4340a13 add the tests
sheep@ghostwheel
parents:
diff changeset
82 ('another', 'link'),
079da4340a13 add the tests
sheep@ghostwheel
parents:
diff changeset
83 ('link', 'link'),
079da4340a13 add the tests
sheep@ghostwheel
parents:
diff changeset
84 ]
771
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
85
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
86 def test_basic_paragraph(self):
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
87 html = parse(u'ziew')
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
88 assert html == '<p id="line_0">ziew</p>'
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
89
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
90 def test_amp(self):
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
91 html = parse(u"d&d")
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
92 assert html == """<p id="line_0">d&amp;d</p>"""
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
93
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
94 def test_basic_header(self):
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
95 html = parse(u"= head =")
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
96 assert html == """<a name="head-1"></a><h1 id="line_0">head</h1>"""
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
97
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
98 def test_paragraph_newline(self):
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
99 html = parse(u'test\ntest')
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
100 assert html == """<p id="line_0">test
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
101 test</p>"""
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
102
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
103 def test_two_paragraphs(self):
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
104 html = parse(u'test\n\ntest')
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
105 assert html == """<p id="line_0">test</p><p id="line_2">test</p>"""
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
106
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
107 def test_linebreak(self):
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
108 html = parse(u'test\\\\test')
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
109 assert html == """<p id="line_0">test<br>test</p>"""
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
110
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
111 def test_separator(self):
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
112 html = parse(u'----')
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
113 assert html == """<hr>"""
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
114
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
115 def test_level_two_header(self):
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
116 html = parse(u'==test==')
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
117 assert html == """<a name="head-0-1"></a><h2 id="line_0">test</h2>"""
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
118
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
119 def test_unterminated_header(self):
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
120 html = parse(u'== test')
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
121 assert html == """<a name="head-0-1"></a><h2 id="line_0">test</h2>"""
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
122
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
123 def test_overterminated_header(self):
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
124 html = parse(u'==test====')
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
125 assert html == """<a name="head-0-1"></a><h2 id="line_0">test</h2>"""
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
126
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
127 def test_level_five_header(self):
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
128 html = parse(u'=====test')
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
129 assert html == """<a name="head-0-0-0-0-1"></a><h5 id="line_0">test</h5>"""
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
130
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
131 def test_mix_headers_and_paragraphs(self):
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
132 html = parse(u'==test==\ntest\n===test===')
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
133 assert html == """
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
134 <a name="head-0-1"></a>
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
135 <h2 id="line_0">test</h2>
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
136 <p id="line_1">test</p>
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
137 <a name="head-0-1-1"></a>
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
138 <h3 id="line_2">test</h3>
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
139 """
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
140
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
141 def test_basic_bulltes(self):
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
142 html = parse(u'test\n* test line one\n * test line two\ntest')
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
143 assert html == """
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
144 <p id="line_0">test</p>
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
145 <ul id="line_1">
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
146 <li>test line one</li>
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
147 <li>test line two</li>
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
148 </ul>
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
149 <p id="line_3">test</p>
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
150 """
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
151
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
152 def test_nested_bullets(self):
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
153 html = parse(u'* test line one\n* test line two\n** Nested item')
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
154 assert html == """
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
155 <ul id="line_0">
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
156 <li>test line one</li>
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
157 <li>test line two<ul id="line_2">
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
158 <li>Nested item</li>
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
159 </ul></li>
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
160 </ul>
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
161 """
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
162
2283
c2df8847693c added enumerated lists to the parser
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 2241
diff changeset
163 def test_basic_numbers(self):
c2df8847693c added enumerated lists to the parser
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 2241
diff changeset
164 html = parse(u'test\n# test line one\n # test line two\ntest')
c2df8847693c added enumerated lists to the parser
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 2241
diff changeset
165 assert html == """
c2df8847693c added enumerated lists to the parser
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 2241
diff changeset
166 <p id="line_0">test</p>
c2df8847693c added enumerated lists to the parser
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 2241
diff changeset
167 <ol id="line_1">
c2df8847693c added enumerated lists to the parser
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 2241
diff changeset
168 <li>test line one</li>
c2df8847693c added enumerated lists to the parser
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 2241
diff changeset
169 <li>test line two</li>
c2df8847693c added enumerated lists to the parser
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 2241
diff changeset
170 </ol>
c2df8847693c added enumerated lists to the parser
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 2241
diff changeset
171 <p id="line_3">test</p>
c2df8847693c added enumerated lists to the parser
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 2241
diff changeset
172 """
c2df8847693c added enumerated lists to the parser
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 2241
diff changeset
173
c2df8847693c added enumerated lists to the parser
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 2241
diff changeset
174 def test_nested_numbers(self):
c2df8847693c added enumerated lists to the parser
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 2241
diff changeset
175 html = parse(u'# test line one\n# test line two\n## Nested item')
c2df8847693c added enumerated lists to the parser
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 2241
diff changeset
176 assert html == """
c2df8847693c added enumerated lists to the parser
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 2241
diff changeset
177 <ol id="line_0">
c2df8847693c added enumerated lists to the parser
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 2241
diff changeset
178 <li>test line one</li>
c2df8847693c added enumerated lists to the parser
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 2241
diff changeset
179 <li>test line two<ol id="line_2">
c2df8847693c added enumerated lists to the parser
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 2241
diff changeset
180 <li>Nested item</li>
c2df8847693c added enumerated lists to the parser
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 2241
diff changeset
181 </ol></li>
c2df8847693c added enumerated lists to the parser
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 2241
diff changeset
182 </ol>
c2df8847693c added enumerated lists to the parser
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 2241
diff changeset
183 """
c2df8847693c added enumerated lists to the parser
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 2241
diff changeset
184
2297
3cf37b6cb841 mark failing tests as xfail, add a test for special case with numbered lists
Radomir Dopieralski <sheep@stxnext.pl>
parents: 2283
diff changeset
185 def test_very_nested_numbers(self):
3cf37b6cb841 mark failing tests as xfail, add a test for special case with numbered lists
Radomir Dopieralski <sheep@stxnext.pl>
parents: 2283
diff changeset
186 html = parse(u'# 1\n# 2\n## 2.1\n### 2.1.1\n# 3')
3cf37b6cb841 mark failing tests as xfail, add a test for special case with numbered lists
Radomir Dopieralski <sheep@stxnext.pl>
parents: 2283
diff changeset
187 assert html == """
3cf37b6cb841 mark failing tests as xfail, add a test for special case with numbered lists
Radomir Dopieralski <sheep@stxnext.pl>
parents: 2283
diff changeset
188 <ol id="line_0">
3cf37b6cb841 mark failing tests as xfail, add a test for special case with numbered lists
Radomir Dopieralski <sheep@stxnext.pl>
parents: 2283
diff changeset
189 <li>1</li>
3cf37b6cb841 mark failing tests as xfail, add a test for special case with numbered lists
Radomir Dopieralski <sheep@stxnext.pl>
parents: 2283
diff changeset
190 <li>2<ol id="line_2">
3cf37b6cb841 mark failing tests as xfail, add a test for special case with numbered lists
Radomir Dopieralski <sheep@stxnext.pl>
parents: 2283
diff changeset
191 <li>2.1<ol id="line_3">
3cf37b6cb841 mark failing tests as xfail, add a test for special case with numbered lists
Radomir Dopieralski <sheep@stxnext.pl>
parents: 2283
diff changeset
192 <li>2.1.1</li>
3cf37b6cb841 mark failing tests as xfail, add a test for special case with numbered lists
Radomir Dopieralski <sheep@stxnext.pl>
parents: 2283
diff changeset
193 </ol></li>
3cf37b6cb841 mark failing tests as xfail, add a test for special case with numbered lists
Radomir Dopieralski <sheep@stxnext.pl>
parents: 2283
diff changeset
194 </ol></li>
3cf37b6cb841 mark failing tests as xfail, add a test for special case with numbered lists
Radomir Dopieralski <sheep@stxnext.pl>
parents: 2283
diff changeset
195 <li>3</li>
3cf37b6cb841 mark failing tests as xfail, add a test for special case with numbered lists
Radomir Dopieralski <sheep@stxnext.pl>
parents: 2283
diff changeset
196 </ol>
3cf37b6cb841 mark failing tests as xfail, add a test for special case with numbered lists
Radomir Dopieralski <sheep@stxnext.pl>
parents: 2283
diff changeset
197 """
3cf37b6cb841 mark failing tests as xfail, add a test for special case with numbered lists
Radomir Dopieralski <sheep@stxnext.pl>
parents: 2283
diff changeset
198
2283
c2df8847693c added enumerated lists to the parser
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 2241
diff changeset
199 def test_mixed_numbers_bullets(self):
c2df8847693c added enumerated lists to the parser
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 2241
diff changeset
200 html = parse(u'# test line one\n* test line two\n*# Nested item')
c2df8847693c added enumerated lists to the parser
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 2241
diff changeset
201 assert html == """
c2df8847693c added enumerated lists to the parser
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 2241
diff changeset
202 <ol id="line_0">
c2df8847693c added enumerated lists to the parser
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 2241
diff changeset
203 <li>test line one</li>
c2df8847693c added enumerated lists to the parser
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 2241
diff changeset
204 <li>test line two<ol id="line_2">
c2df8847693c added enumerated lists to the parser
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 2241
diff changeset
205 <li>Nested item</li>
c2df8847693c added enumerated lists to the parser
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 2241
diff changeset
206 </ol></li>
c2df8847693c added enumerated lists to the parser
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 2241
diff changeset
207 </ol>
c2df8847693c added enumerated lists to the parser
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 2241
diff changeset
208 """
c2df8847693c added enumerated lists to the parser
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 2241
diff changeset
209
c2df8847693c added enumerated lists to the parser
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 2241
diff changeset
210 def test_mixed_bullets_numbers(self):
c2df8847693c added enumerated lists to the parser
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 2241
diff changeset
211 html = parse(u'* test line one\n# test line two\n*# Nested item')
c2df8847693c added enumerated lists to the parser
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 2241
diff changeset
212 assert html == """
c2df8847693c added enumerated lists to the parser
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 2241
diff changeset
213 <ul id="line_0">
c2df8847693c added enumerated lists to the parser
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 2241
diff changeset
214 <li>test line one</li>
c2df8847693c added enumerated lists to the parser
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 2241
diff changeset
215 <li>test line two<ul id="line_2">
c2df8847693c added enumerated lists to the parser
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 2241
diff changeset
216 <li>Nested item</li>
c2df8847693c added enumerated lists to the parser
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 2241
diff changeset
217 </ul></li>
c2df8847693c added enumerated lists to the parser
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 2241
diff changeset
218 </ul>
c2df8847693c added enumerated lists to the parser
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 2241
diff changeset
219 """
c2df8847693c added enumerated lists to the parser
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 2241
diff changeset
220
771
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
221 def test_basic_emphasis(self):
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
222 html = parse(u'test //test test// test **test test** test')
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
223 assert html == """<p id="line_0">test <i>test test</i> test <b>test test</b> test</p>"""
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
224
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
225 def test_nested_emphasis(self):
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
226 html = parse(u'test //test **test// test** test')
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
227 assert html == """<p id="line_0">test <i>test <b>test</b></i> test<b> test</b></p>"""
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
228
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
229 def test_unterminated_emphasis(self):
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
230 html = parse(u'**test')
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
231 assert html == """<p id="line_0"><b>test</b></p>"""
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
232
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
233 def test_basic_table(self):
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
234 html = parse(u'|x|y|z|\n|a|b|c|\n|d|e|f|\ntest')
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
235 assert html == """
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
236 <table id="line_0">
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
237 <tr>
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
238 <td>x</td>
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
239 <td>y</td>
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
240 <td>z</td>
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
241 </tr>
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
242 <tr>
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
243 <td>a</td>
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
244 <td>b</td>
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
245 <td>c</td>
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
246 </tr>
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
247 <tr>
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
248 <td>d</td>
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
249 <td>e</td>
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
250 <td>f</td>
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
251 </tr>
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
252 </table>
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
253 <p id="line_3">test</p>
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
254 """
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
255
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
256 def test_table_with_head(self):
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
257 html = parse(u'|=x|y|=z=|\n|a|b|c|\n|d|e|=f=|')
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
258 assert html == """
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
259 <table id="line_0">
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
260 <thead><tr>
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
261 <th>x</th>
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
262 <td>y</td>
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
263 <th>z</th>
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
264 </tr></thead>
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
265 <tr>
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
266 <td>a</td>
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
267 <td>b</td>
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
268 <td>c</td>
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
269 </tr>
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
270 <tr>
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
271 <td>d</td>
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
272 <td>e</td>
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
273 <th>f</th>
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
274 </tr>
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
275 </table>
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
276 """
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
277
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
278 def test_free_url(self):
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
279 html = parse(u'test http://example.com/test test')
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
280 assert html == """
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
281 <p id="line_0">
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
282 test <a href="http://example.com/test">
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
283 http://example.com/test
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
284 </a> test
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
285 </p>
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
286 """
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
287
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
288 def test_free_url_with_commas(self):
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
289 html = parse(u'http://example.com/,test, test')
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
290 assert html == """
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
291 <p id="line_0">
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
292 <a href="http://example.com/,test">http://example.com/,test</a>, test
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
293 </p>
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
294 """
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
295
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
296 def test_free_url_with_parens(self):
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
297 html = parse(u'(http://example.com/test)')
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
298 assert html == """
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
299 <p id="line_0">
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
300 (<a href="http://example.com/test">http://example.com/test</a>)
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
301 </p>
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
302 """
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
303
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
304 # This might be considered a bug, but impossible to detect in general.
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
305 html = parse(u'http://example.com/(test)')
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
306 assert html == """
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
307 <p id="line_0">
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
308 <a href="http://example.com/(test">http://example.com/(test</a>)
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
309 </p>
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
310 """
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
311
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
312 def test_free_url_with_query_string(self):
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
313 html = parse(u'http://example.com/test?test&test=1')
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
314 assert html == """
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
315 <p id="line_0">
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
316 <a href="http://example.com/test?test&amp;test=1"> http://example.com/test?test&amp;test=1
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
317 </a></p>
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
318 """
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
319
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
320 def test_free_url_with_tilde(self):
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
321 html = parse(u'http://example.com/~test')
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
322 assert html == """
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
323 <p id="line_0">
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
324 <a href="http://example.com/~test">http://example.com/~test</a>
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
325 </p>
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
326 """
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
327
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
328 def test_wiki_link(self):
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
329 html = parse(u'[[test]] [[tset|test]]')
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
330 assert html == """
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
331 <p id="line_0">
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
332 <a href="test">test</a> <a href="tset">test</a>
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
333 </p>
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
334 """
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
335
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
336 def test_url_link(self):
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
337 html = parse(u'[[http://example.com|test]]')
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
338 assert html == """
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
339 <p id="line_0">
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
340 <a href="http://example.com">test</a>
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
341 </p>
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
342 """
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
343
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
344 def test_pre(self):
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
345 html = parse(u'{{{\nlorem ipsum\n}}}')
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
346 assert html == """<pre id="line_1" class="code">lorem ipsum</pre>"""
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
347
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
348 def test_text(self):
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
349 html = parse(u'{{{#!text\nlorem ipsum\n}}}')
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
350 assert html == """<div class="highlight"><pre><span id="line_1">lorem ipsum</span></pre></div>"""
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
351
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
352 def test_highlight(self):
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
353 html = parse(u'{{{#!c++\nint eger;\n}}}')
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
354 assert html == """<div class="highlight"><pre><span id="line_1"><span class="kt">int</span> <span class="n">eger</span><span class="p">;</span></span></pre></div>"""
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
355
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
356 def test_basic_table(self):
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
357 html = parse(u'|table|')
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
358 assert html == """<table id="line_0"><tr><td>table</td></tr></table>"""
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
359
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
360 def test_two_cell_table(self):
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
361 html = parse(u'|table| cell |')
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
362 assert html == """<table id="line_0"><tr><td>table</td><td> cell </td></tr></table>"""
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
363
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
364 def test_table_head(self):
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
365 html = parse(u'|table|=head=|')
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
366 assert html == """<table id="line_0"><tr><td>table</td><th>head</th></tr></table>"""
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
367
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
368 def test_table_head_row(self):
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
369 html = parse(u'|=table=|=head=|')
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
370 assert html == """<table id="line_0"><thead><tr><th>table</th><th>head</th></tr></thead></table>"""
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
371
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
372 def test_table_link(self):
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
373 html = parse(u'|table|[[link|link]]|')
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
374 assert html == """<table id="line_0"><tr><td>table</td><td><a href="link">link</a></td></tr></table>"""
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
375
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
376 def test_table_image(self):
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
377 html = parse(u'|table|{{img|img}}|')
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
378 assert html == """<table id="line_0"><tr><td>table</td><td><img src="img" alt="img"></td></tr></table>"""
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
379
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
380 def test_table_pre(self):
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
381 html = parse(u'|table|{{{code|code}}}|')
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
382 assert html == """<table id="line_0"><tr><td>table</td><td><code>code|code</code></td></tr></table>"""
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
383
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
384 def test_wiki_word(self):
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
385 html = wiki_parse(u'some wikiWord, here')
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
386 assert html == """<p id="line_0">some <a href="wikiWord">wikiWord</a>, here</p>"""
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
387
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
388 def test_wiki_word_escape(self):
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
389 html = wiki_parse(u'no !wikiWord here, ~wikiWord')
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
390 assert html == """<p id="line_0">no wikiWord here, wikiWord</p>"""
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
391
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
392 def test_emoticon(self):
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
393 html = parse(u'lol:)')
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
394 assert html == """<p id="line_0">lol<img src="smile.png" alt=":)"></p>"""
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
395
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
396 def test_monotype(self):
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
397 html = parse(u'This is ##monotyped## text.')
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
398 assert html == """<p id="line_0">This is <tt>monotyped</tt> text.</p>"""
38c1e8dd7769 move the parser tests from docstrings to py.test
Radomir Dopieralski <hatta-dev@sheep.art.pl>
parents: 431
diff changeset
399
2485
c2bd1f3dcd4b Recursive block quote parsing
Sam Toyer <sam@qxcv.net>
parents: 2297
diff changeset
400 def test_inline_quote(self):
c2bd1f3dcd4b Recursive block quote parsing
Sam Toyer <sam@qxcv.net>
parents: 2297
diff changeset
401 html = parse(u'> //Simple// quote with\n> one paragraph')
c2bd1f3dcd4b Recursive block quote parsing
Sam Toyer <sam@qxcv.net>
parents: 2297
diff changeset
402 assert html == """
c2bd1f3dcd4b Recursive block quote parsing
Sam Toyer <sam@qxcv.net>
parents: 2297
diff changeset
403 <blockquote>
c2bd1f3dcd4b Recursive block quote parsing
Sam Toyer <sam@qxcv.net>
parents: 2297
diff changeset
404 <p id="line_0"><i>Simple</i> quote with\none paragraph</p>
c2bd1f3dcd4b Recursive block quote parsing
Sam Toyer <sam@qxcv.net>
parents: 2297
diff changeset
405 </blockquote>
c2bd1f3dcd4b Recursive block quote parsing
Sam Toyer <sam@qxcv.net>
parents: 2297
diff changeset
406 """
c2bd1f3dcd4b Recursive block quote parsing
Sam Toyer <sam@qxcv.net>
parents: 2297
diff changeset
407
c2bd1f3dcd4b Recursive block quote parsing
Sam Toyer <sam@qxcv.net>
parents: 2297
diff changeset
408 def test_block_quote(self):
c2bd1f3dcd4b Recursive block quote parsing
Sam Toyer <sam@qxcv.net>
parents: 2297
diff changeset
409 html = parse(u'> //Complex// quote\n> with\n>\n> = extra markup')
c2bd1f3dcd4b Recursive block quote parsing
Sam Toyer <sam@qxcv.net>
parents: 2297
diff changeset
410 assert html == """
c2bd1f3dcd4b Recursive block quote parsing
Sam Toyer <sam@qxcv.net>
parents: 2297
diff changeset
411 <blockquote>
c2bd1f3dcd4b Recursive block quote parsing
Sam Toyer <sam@qxcv.net>
parents: 2297
diff changeset
412 <p id="line_0"><i>Complex</i> quote\nwith</p>
c2bd1f3dcd4b Recursive block quote parsing
Sam Toyer <sam@qxcv.net>
parents: 2297
diff changeset
413 <a name="head-1"></a><h1 id="line_3">extra markup</h1>
c2bd1f3dcd4b Recursive block quote parsing
Sam Toyer <sam@qxcv.net>
parents: 2297
diff changeset
414 </blockquote>
c2bd1f3dcd4b Recursive block quote parsing
Sam Toyer <sam@qxcv.net>
parents: 2297
diff changeset
415 """
c2bd1f3dcd4b Recursive block quote parsing
Sam Toyer <sam@qxcv.net>
parents: 2297
diff changeset
416
c2bd1f3dcd4b Recursive block quote parsing
Sam Toyer <sam@qxcv.net>
parents: 2297
diff changeset
417 def test_nested_quotes(self):
c2bd1f3dcd4b Recursive block quote parsing
Sam Toyer <sam@qxcv.net>
parents: 2297
diff changeset
418 html = parse(u'> Outer quote\n>> Inner quote')
c2bd1f3dcd4b Recursive block quote parsing
Sam Toyer <sam@qxcv.net>
parents: 2297
diff changeset
419 assert html == """
c2bd1f3dcd4b Recursive block quote parsing
Sam Toyer <sam@qxcv.net>
parents: 2297
diff changeset
420 <blockquote>
c2bd1f3dcd4b Recursive block quote parsing
Sam Toyer <sam@qxcv.net>
parents: 2297
diff changeset
421 <p id="line_0">Outer quote</p>
c2bd1f3dcd4b Recursive block quote parsing
Sam Toyer <sam@qxcv.net>
parents: 2297
diff changeset
422 <blockquote>
c2bd1f3dcd4b Recursive block quote parsing
Sam Toyer <sam@qxcv.net>
parents: 2297
diff changeset
423 <p id="line_1">Inner quote</p>
c2bd1f3dcd4b Recursive block quote parsing
Sam Toyer <sam@qxcv.net>
parents: 2297
diff changeset
424 </blockquote>
c2bd1f3dcd4b Recursive block quote parsing
Sam Toyer <sam@qxcv.net>
parents: 2297
diff changeset
425 </blockquote>
c2bd1f3dcd4b Recursive block quote parsing
Sam Toyer <sam@qxcv.net>
parents: 2297
diff changeset
426 """
c2bd1f3dcd4b Recursive block quote parsing
Sam Toyer <sam@qxcv.net>
parents: 2297
diff changeset
427