/
test_markdown_unittest.py
87 lines (72 loc) · 2.5 KB
/
test_markdown_unittest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
'''
Test markdown.py with unittest
To run tests:
python test_markdown_unittest.py
'''
import unittest
from markdown_adapter import run_markdown
class TestMarkdownPy(unittest.TestCase):
def setUp(self):
pass
def test_non_marked_lines(self):
'''
Non-marked lines should only get 'p' tags around all input
'''
self.assertEqual(
run_markdown('this line has no special handling'),
'<p>this line has no special handling</p>')
def test_em(self):
'''
Lines surrounded by asterisks should be wrapped in 'em' tags
'''
self.assertEqual(
run_markdown('*this should be wrapped in em tags*'),
'<p><em>this should be wrapped in em tags</em></p>')
def test_strong(self):
'''
Lines surrounded by double asterisks should be wrapped in 'strong' tags
'''
self.assertEqual(
run_markdown('**this should be wrapped in strong tags**'),
'<p><strong>this should be wrapped in strong tags</strong></p>')
def test_h1(self):
'''
Lines beginning with # should be wrapped in 'h1' tags
'''
self.assertEqual(
run_markdown('#This line should be wrapped in h1 tags'),
'<p><h1>This line should be wrapped in h1 tags</h1></p>')
def test_h2(self):
'''
Lines beginning with ## should be wrapped in 'h2' tags
'''
self.assertEqual(
run_markdown('##This line should be wrapped in h2 tags'),
'<p><h2>This line should be wrapped in h2 tags</h2></p>')
def test_h3(self):
'''
Lines beginning with ### should be wrapped in 'h3' tags
'''
self.assertEqual(
run_markdown('###This line should be wrapped in h3 tags'),
'<p><h3>This line should be wrapped in h3 tags</h3></p>')
def test_blockquote(self):
'''
Testing:
> #This
> Line
> Is a
> Blockquote
should equal to:
<blockquote>
<p><h1>This</h1></p>
<p>Line</p>
<p>Is a</p>
<p>Blockquote</p>
</blockquote>
'''
self.assertEqual(
run_markdown('> #This\n> Line\n> Is a\n> Blockquote'),
'<blockquote> <p><h1>This</h1></p> <p>Line</p> <p>Is a</p> <p>Blockquote</p> </blockquote>')
if __name__ == '__main__':
unittest.main()