-
Notifications
You must be signed in to change notification settings - Fork 0
/
tests.py
67 lines (54 loc) · 1.4 KB
/
tests.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
import unittest
import sharpy
class TestHtml(unittest.TestCase):
def test_element(self):
h = sharpy.html()
page = h.html()('An empty page')
html = '''<html>
An empty page
</html>'''
self.assertEqual(html, h.dumps(page))
def test_nested_element(self):
h = sharpy.html()
page = h.html()([
h.body()("Body text")])
html = '''<html>
<body>
Body text
</body>
</html>'''
self.assertEqual(html, h.dumps(page))
def test_element_attributes(self):
h = sharpy.html()
page = h.p(id='intro', _class="intro")('Intro paragraph')
html = '''<p class="intro" id="intro">
Intro paragraph
</p>'''
self.assertEqual(html, h.dumps(page))
def test_href(self):
h = sharpy.html()
page = h.a(href='https://github.com/maplambda/sharpy')('sharpy')
html = '''<a href="https://github.com/maplambda/sharpy">
sharpy
</a>'''
self.assertEqual(html, h.dumps(page))
def test_multiple_nested_elements(self):
h = sharpy.html()
page = h.html()([
h.body()([
h.h1()('sharpy'),
h.p(id='intro')('Intro paragraph')])
])
html = '''<html>
<body>
<h1>
sharpy
</h1>
<p id="intro">
Intro paragraph
</p>
</body>
</html>'''
self.assertEqual(html, h.dumps(page))
if __name__ == '__main__':
unittest.main()