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
Mikolaï Krol
erp5
Commits
2a3df9dd
Commit
2a3df9dd
authored
Sep 30, 2013
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
testXHTML: use suprocess instead of obsolete popen and close file descriptors explicitly
parent
b90ff38c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
13 deletions
+11
-13
product/ERP5/tests/testXHTML.py
product/ERP5/tests/testXHTML.py
+11
-13
No files found.
product/ERP5/tests/testXHTML.py
View file @
2a3df9dd
...
@@ -29,7 +29,6 @@
...
@@ -29,7 +29,6 @@
import
unittest
import
unittest
import
os
import
os
import
popen2
import
urllib
import
urllib
from
subprocess
import
Popen
,
PIPE
from
subprocess
import
Popen
,
PIPE
...
@@ -450,15 +449,14 @@ class W3Validator(object):
...
@@ -450,15 +449,14 @@ class W3Validator(object):
# Zope 2.12 renders page templates as unicode
# Zope 2.12 renders page templates as unicode
page_source
=
page_source
.
encode
(
'utf-8'
)
page_source
=
page_source
.
encode
(
'utf-8'
)
source
=
'fragment=%s&output=soap12'
%
urllib
.
quote_plus
(
page_source
)
source
=
'fragment=%s&output=soap12'
%
urllib
.
quote_plus
(
page_source
)
os
.
environ
[
'CONTENT_LENGTH'
]
=
str
(
len
(
source
))
stdout
,
stderr
=
Popen
(
self
.
validator_path
,
os
.
environ
[
'REQUEST_METHOD'
]
=
'POST'
stdin
=
PIPE
,
stdout
=
PIPE
,
stderr
=
PIPE
,
stdout
,
stdin
,
stderr
=
popen2
.
popen3
(
self
.
validator_path
)
close_fds
=
True
,
stdin
.
write
(
source
)
env
=
{
"CONTENT_LENGTH"
:
str
(
len
(
source
)),
stdin
.
close
()
"REQUEST_METHOD"
:
"POST"
}).
communicate
(
source
)
while
stdout
.
readline
()
!=
'
\
n
'
:
# Output is a set of headers then the XML content.
pass
return
self
.
_parse_validation_results
(
result
=
stdout
.
read
()
stdout
.
split
(
'<?xml version="1.0" encoding="UTF-8"?>'
)[
1
])
return
self
.
_parse_validation_results
(
result
)
class
TidyValidator
(
object
):
class
TidyValidator
(
object
):
...
@@ -498,9 +496,9 @@ class TidyValidator(object):
...
@@ -498,9 +496,9 @@ class TidyValidator(object):
'''
'''
retrun two list : a list of errors and an other for warnings
retrun two list : a list of errors and an other for warnings
'''
'''
stdout
,
std
in
,
stderr
=
popen2
.
popen3
(
'%s -e -q -utf8'
%
self
.
validator_path
)
stdout
,
std
err
=
Popen
(
'%s -e -q -utf8'
%
self
.
validator_path
,
stdin
.
write
(
page_source
)
stdin
=
PIPE
,
stdout
=
PIPE
,
stderr
=
PIPE
,
stdin
.
close
(
)
close_fds
=
True
).
communicate
(
page_source
)
return
self
.
_parse_validation_results
(
stderr
)
return
self
.
_parse_validation_results
(
stderr
)
...
...
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