FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
html5lib-python/tests/test_validator.py at python3-old · mfa/html5lib-python · GitHub
mfa
/
html5lib-python
Public
forked from
html5lib/html5lib-python
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
html5lib-python
/
tests
/
test_validator.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
executable file
·
32 lines (28 loc) · 1.23 KB
Breadcrumbs
html5lib-python
/
tests
/
test_validator.py
Copy path
File metadata and controls
executable file
·
32 lines (28 loc) · 1.23 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
import
os
,
unittest
from
support
import
simplejson
,
html5lib_test_files
from
html5lib
.
html5parser
import
HTMLParser
from
html5lib
.
filters
.
validator
import
HTMLConformanceChecker
class
TestCase
(
unittest
.
TestCase
):
def
runValidatorTest
(
self
,
test
):
p
=
HTMLParser
(
tokenizer
=
HTMLConformanceChecker
)
p
.
parse
(
test
[
'input'
])
errorCodes
=
[
errorcode
for
position
,
errorcode
,
datavars
in
p
.
errors
]
if
test
.
has_key
(
'fail-if'
):
self
.
failIf
(
test
[
'fail-if'
]
in
errorCodes
)
if
test
.
has_key
(
'fail-unless'
):
self
.
failUnless
(
test
[
'fail-unless'
]
in
errorCodes
)
def
buildTestSuite
():
for
filename
in
html5lib_test_files
(
'validator'
,
'*.test'
):
tests
=
simplejson
.
load
(
file
(
filename
))
testName
=
os
.
path
.
basename
(
filename
).
replace
(
".test"
,
""
)
for
index
,
test
in
enumerate
(
tests
[
'tests'
]):
def
testFunc
(
self
,
test
=
test
):
self
.
runValidatorTest
(
test
)
testFunc
.
__doc__
=
"
\t
"
.
join
([
testName
,
test
[
'description'
]])
setattr
(
TestCase
,
'test_%s_%d'
%
(
testName
,
index
),
testFunc
)
return
unittest
.
TestLoader
().
loadTestsFromTestCase
(
TestCase
)
def
main
():
buildTestSuite
()
unittest
.
main
()
if
__name__
==
"__main__"
:
main
()
Back
|
FazBrowse Home
|
New Git URL