Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1df7e5f

Browse files
committed
Cleanup test_parser2.py a bit
1 parent3065630 commit1df7e5f

File tree

1 file changed

+20
-24
lines changed

1 file changed

+20
-24
lines changed

‎html5lib/tests/test_parser2.py

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,51 +7,47 @@
77
from .importsupport# flake8: noqa
88
fromhtml5libimporthtml5parser
99
fromhtml5lib.constantsimportnamespaces
10-
fromhtml5libimporttreebuilders
10+
fromhtml5libimportparse
1111

1212

1313
# tests that aren't autogenerated from text files
14-
@pytest.fixture
15-
defdom_tree():
16-
returntreebuilders.getTreeBuilder("dom")
17-
18-
19-
deftest_assertDoctypeCloneable(dom_tree):
20-
parser=html5parser.HTMLParser(tree=dom_tree)
21-
doc=parser.parse('<!DOCTYPE HTML>')
14+
deftest_assertDoctypeCloneable():
15+
doc=parse('<!DOCTYPE HTML>',treebuilder="dom")
2216
assertdoc.cloneNode(True)isnotNone
2317

2418

25-
deftest_line_counter(dom_tree):
19+
deftest_line_counter():
2620
# http://groups.google.com/group/html5lib-discuss/browse_frm/thread/f4f00e4a2f26d5c0
27-
parser=html5parser.HTMLParser(tree=dom_tree)
28-
parser.parse("<pre>\nx\n&gt;\n</pre>")
21+
assertparse("<pre>\nx\n&gt;\n</pre>")isnotNone
2922

3023

31-
deftest_namespace_html_elements_0_dom(dom_tree):
32-
parser=html5parser.HTMLParser(tree=dom_tree,namespaceHTMLElements=True)
33-
doc=parser.parse("<html></html>")
24+
deftest_namespace_html_elements_0_dom():
25+
doc=parse("<html></html>",
26+
treebuilder="dom",
27+
namespaceHTMLElements=True)
3428
assertdoc.childNodes[0].namespaceURI==namespaces["html"]
3529

3630

37-
deftest_namespace_html_elements_1_dom(dom_tree):
38-
parser=html5parser.HTMLParser(tree=dom_tree,namespaceHTMLElements=False)
39-
doc=parser.parse("<html></html>")
31+
deftest_namespace_html_elements_1_dom():
32+
doc=parse("<html></html>",
33+
treebuilder="dom",
34+
namespaceHTMLElements=False)
4035
assertdoc.childNodes[0].namespaceURIisNone
4136

4237

4338
deftest_namespace_html_elements_0_etree():
44-
parser=html5parser.HTMLParser(namespaceHTMLElements=True)
45-
doc=parser.parse("<html></html>")
39+
doc=parse("<html></html>",
40+
treebuilder="etree",
41+
namespaceHTMLElements=True)
4642
assertdoc.tag=="{%s}html"% (namespaces["html"],)
4743

4844

4945
deftest_namespace_html_elements_1_etree():
50-
parser=html5parser.HTMLParser(namespaceHTMLElements=False)
51-
doc=parser.parse("<html></html>")
46+
doc=parse("<html></html>",
47+
treebuilder="etree",
48+
namespaceHTMLElements=False)
5249
assertdoc.tag=="html"
5350

5451

5552
deftest_unicode_file():
56-
parser=html5parser.HTMLParser()
57-
parser.parse(io.StringIO("a"))
53+
assertparse(io.StringIO("a"))isnotNone

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp