-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathtest_parser2.py
More file actions
executable file
·53 lines (42 loc) · 1.69 KB
/
test_parser2.py
File metadata and controls
executable file
·53 lines (42 loc) · 1.69 KB
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
from __future__ import absolute_import
import io
from . import support
from html5lib import html5parser
from html5lib.constants import namespaces
from html5lib.treebuilders import dom
import unittest
# tests that aren't autogenerated from text files
class MoreParserTests(unittest.TestCase):
def test_assertDoctypeCloneable(self):
parser = html5parser.HTMLParser(tree=dom.TreeBuilder)
doc = parser.parse(u'<!DOCTYPE HTML>')
self.assert_(doc.cloneNode(True))
test_assertDoctypeCloneable.func_annotations = {}
def test_line_counter(self):
# http://groups.google.com/group/html5lib-discuss/browse_frm/thread/f4f00e4a2f26d5c0
parser = html5parser.HTMLParser(tree=dom.TreeBuilder)
parser.parse(u"<pre>\nx\n>\n</pre>")
test_line_counter.func_annotations = {}
def test_namespace_html_elements_0(self):
parser = html5parser.HTMLParser(namespaceHTMLElements=True)
doc = parser.parse(u"<html></html>")
self.assert_(doc.childNodes[0].namespace == namespaces[u"html"])
test_namespace_html_elements_0.func_annotations = {}
def test_namespace_html_elements_1(self):
parser = html5parser.HTMLParser(namespaceHTMLElements=False)
doc = parser.parse(u"<html></html>")
self.assert_(doc.childNodes[0].namespace == None)
test_namespace_html_elements_1.func_annotations = {}
def test_unicode_file(self):
parser = html5parser.HTMLParser()
doc = parser.parse(io.StringIO(u"a"))
test_unicode_file.func_annotations = {}
def buildTestSuite():
return unittest.defaultTestLoader.loadTestsFromName(__name__)
buildTestSuite.func_annotations = {}
def main():
buildTestSuite()
unittest.main()
main.func_annotations = {}
if __name__ == u'__main__':
main()