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
Richard
erp5
Commits
e879c6f9
Commit
e879c6f9
authored
Mar 15, 2018
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
testXHTML: use the global validator to check static html files
Reduce duplicated code.
parent
c0707087
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
46 deletions
+38
-46
product/ERP5/tests/testXHTML.py
product/ERP5/tests/testXHTML.py
+38
-46
No files found.
product/ERP5/tests/testXHTML.py
View file @
e879c6f9
...
@@ -225,54 +225,46 @@ class TestXHTMLMixin(ERP5TypeTestCase):
...
@@ -225,54 +225,46 @@ class TestXHTMLMixin(ERP5TypeTestCase):
self
.
fail
(
message
)
self
.
fail
(
message
)
def
test_html_file
(
self
):
def
test_html_file
(
self
):
path_list
=
os
.
environ
.
get
(
'CGI_PATH'
,
skins_tool
=
self
.
portal
.
portal_skins
'/usr/lib/cgi-bin:/usr/lib/cgi-bin/w3c-markup-validator'
).
split
(
os
.
pathsep
)
path_list
=
[]
for
path
in
path_list
:
for
script_path
,
script
in
skins_tool
.
ZopeFind
(
validator_path
=
os
.
path
.
join
(
path
,
'check'
)
skins_tool
,
obj_metatypes
=
[
'File'
],
search_sub
=
1
):
if
os
.
path
.
exists
(
validator_path
):
is_required_check_path
=
True
validator
=
W3Validator
(
validator_path
,
show_warnings
)
ignore_bts
=
[
'erp5_jquery'
,
'erp5_fckeditor'
,
'erp5_svg_editor'
,
'erp5_jquery_ui'
]
break
if
script_path
.
endswith
(
'.html'
):
if
validator
is
not
None
:
for
ignore_bt_name
in
ignore_bts
:
skins_tool
=
self
.
portal
.
portal_skins
if
script_path
.
startswith
(
ignore_bt_name
):
path_list
=
[]
is_required_check_path
=
False
for
script_path
,
script
in
skins_tool
.
ZopeFind
(
break
;
skins_tool
,
obj_metatypes
=
[
'File'
],
search_sub
=
1
):
if
is_required_check_path
:
is_required_check_path
=
True
path_list
.
append
(
script_path
)
ignore_bts
=
[
'erp5_jquery'
,
'erp5_fckeditor'
,
'erp5_svg_editor'
,
'erp5_jquery_ui'
]
if
script_path
.
endswith
(
'.html'
):
def
validate_html_file
(
source_path
):
for
ignore_bt_name
in
ignore_bts
:
message
=
[
'Using %s validator to parse the file "%s"'
if
script_path
.
startswith
(
ignore_bt_name
):
' with warnings%sdisplayed :'
is_required_check_path
=
False
%
(
validator
.
name
,
source_path
,
break
;
validator
.
show_warnings
and
' '
or
' NOT '
)]
if
is_required_check_path
:
source
=
self
.
publish
(
source_path
).
getBody
()
path_list
.
append
(
script_path
)
result_list_list
=
validator
.
getErrorAndWarningList
(
source
)
severity_list
=
[
'Error'
]
def
validate_html_file
(
source_path
):
if
validator
.
show_warnings
:
message
=
[
'Using %s validator to parse the file "%s"'
severity_list
.
append
(
'Warning'
)
' with warnings%sdisplayed :'
for
i
,
severity
in
enumerate
(
severity_list
):
%
(
validator
.
name
,
source_path
,
for
line
,
column
,
msg
in
result_list_list
[
i
]:
validator
.
show_warnings
and
' '
or
' NOT '
)]
if
line
is
None
and
column
is
None
:
source
=
self
.
publish
(
source_path
).
getBody
()
message
.
append
(
'%s: %s'
%
(
severity
,
msg
))
result_list_list
=
validator
.
getErrorAndWarningList
(
source
)
else
:
severity_list
=
[
'Error'
]
message
.
append
(
'%s: line %s column %s : %s'
%
if
validator
.
show_warnings
:
(
severity
,
line
,
column
,
msg
))
severity_list
.
append
(
'Warning'
)
return
len
(
message
)
==
1
,
'
\
n
'
.
join
(
message
)
for
i
,
severity
in
enumerate
(
severity_list
):
for
line
,
column
,
msg
in
result_list_list
[
i
]:
if
line
is
None
and
column
is
None
:
message
.
append
(
'%s: %s'
%
(
severity
,
msg
))
else
:
message
.
append
(
'%s: line %s column %s : %s'
%
(
severity
,
line
,
column
,
msg
))
return
len
(
message
)
==
1
,
'
\
n
'
.
join
(
message
)
def
html_file
(
check_path
):
def
html_file
(
check_path
):
self
.
assert_
(
*
validate_html_file
(
source_path
=
check_path
))
self
.
assert_
(
*
validate_html_file
(
source_path
=
check_path
))
portal_skins_path
=
'%s/portal_skins'
%
self
.
portal
.
getId
()
portal_skins_path
=
'%s/portal_skins'
%
self
.
portal
.
getId
()
for
path
in
path_list
:
for
path
in
path_list
:
check_path
=
'%s/%s'
%
(
portal_skins_path
,
path
)
check_path
=
'%s/%s'
%
(
portal_skins_path
,
path
)
html_file
(
check_path
)
html_file
(
check_path
)
def
test_PythonScriptSyntax
(
self
):
def
test_PythonScriptSyntax
(
self
):
"""
"""
...
...
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