Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Romain Courteaud
erp5
Commits
3694ff88
Commit
3694ff88
authored
Mar 13, 2018
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
testXHTML: detect when w3 validator fails
parent
75e48fc4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
0 deletions
+23
-0
product/ERP5/tests/testXHTML.py
product/ERP5/tests/testXHTML.py
+23
-0
No files found.
product/ERP5/tests/testXHTML.py
View file @
3694ff88
...
@@ -542,6 +542,27 @@ class W3Validator(object):
...
@@ -542,6 +542,27 @@ class W3Validator(object):
parses the validation results, returns a list of tuples:
parses the validation results, returns a list of tuples:
line_number, col_number, error description
line_number, col_number, error description
"""
"""
# Output is a set of headers then the XML content.
header_txt
,
body_txt
=
result
.
split
(
'
\
n
\
n
'
,
1
)
# First, search the X-W3C headers
validator_status
=
'Unknown'
error_count
=
-
1
warning_count
=
-
1
for
header_line
in
header_txt
.
split
(
'
\
n
'
):
if
header_line
.
startswith
(
'X-W3C-Validator-Status: '
):
validator_status
=
header_line
[
len
(
'X-W3C-Validator-Status: '
):]
elif
header_line
.
startswith
(
'X-W3C-Validator-Errors: '
):
error_count
=
int
(
header_line
[
len
(
'X-W3C-Validator-Errors: '
):])
elif
header_line
.
startswith
(
'X-W3C-Validator-Warnings: '
):
warning_count
=
int
(
header_line
[
len
(
'X-W3C-Validator-Warnings: '
):])
if
validator_status
==
'Valid'
:
return
[[],
[]]
if
validator_status
!=
'Invalid'
:
return
[[(
None
,
None
,
'Wrong validator status: %s'
%
validator_status
)],
[]]
# Parsing is invalid
result_list_list
=
[]
result_list_list
=
[]
try
:
try
:
xml_doc
=
minidom
.
parseString
(
result
)
xml_doc
=
minidom
.
parseString
(
result
)
...
@@ -567,6 +588,8 @@ class W3Validator(object):
...
@@ -567,6 +588,8 @@ class W3Validator(object):
result
.
append
(
None
)
result
.
append
(
None
)
result_list
.
append
(
tuple
(
result
))
result_list
.
append
(
tuple
(
result
))
result_list_list
.
append
(
result_list
)
result_list_list
.
append
(
result_list
)
if
(
len
(
result_list_list
[
0
])
!=
error_count
)
or
(
len
(
result_list_list
[
1
])
!=
warning_count
):
result_list_list
[
0
].
append
((
None
,
None
,
'Could not parse all errors/warnings'
))
return
result_list_list
return
result_list_list
def
getErrorAndWarningList
(
self
,
page_source
):
def
getErrorAndWarningList
(
self
,
page_source
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment