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
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Amer
erp5
Commits
a5c5cf58
Commit
a5c5cf58
authored
Mar 13, 2018
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
testXHTML: detect when w3 validator fails
parent
417ff1ae
Changes
1
Show 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 @
a5c5cf58
...
...
@@ -562,6 +562,27 @@ class W3Validator(object):
parses the validation results, returns a list of tuples:
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
=
[]
try
:
xml_doc
=
minidom
.
parseString
(
result
)
...
...
@@ -587,6 +608,8 @@ class W3Validator(object):
result
.
append
(
None
)
result_list
.
append
(
tuple
(
result
))
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
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