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
Alexander Emmerich
erp5
Commits
0ef616f2
Commit
0ef616f2
authored
Oct 14, 2022
by
Kazuhiko Shiozaki
Committed by
Arnaud Fontaine
Mar 09, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
py2/py3: use BytesIO for bytes.
parent
22da6ba0
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
20 deletions
+21
-20
bt5/erp5_corporate_identity_test/TestTemplateItem/portal_components/test.erp5.testCorporateIdentityTemplateList.py
...components/test.erp5.testCorporateIdentityTemplateList.py
+3
-3
bt5/erp5_payroll_l10n_fr/TestTemplateItem/portal_components/test.erp5.testSimplifiedPayslipReport.py
...ortal_components/test.erp5.testSimplifiedPayslipReport.py
+3
-3
product/ERP5OOo/tests/testOOoDynamicStyle.py
product/ERP5OOo/tests/testOOoDynamicStyle.py
+11
-10
product/Zelenium/tests/test_zuite.py
product/Zelenium/tests/test_zuite.py
+4
-4
No files found.
bt5/erp5_corporate_identity_test/TestTemplateItem/portal_components/test.erp5.testCorporateIdentityTemplateList.py
View file @
0ef616f2
...
...
@@ -28,7 +28,7 @@
from
Products.ERP5Type.tests.ERP5TypeTestCase
import
ERP5TypeTestCase
from
Products.Localizer.itools.i18n.accept
import
AcceptLanguage
from
PIL
import
Image
import
cString
IO
from
io
import
Bytes
IO
import
math
import
os.path
from
lxml.html
import
fromstring
,
tostring
...
...
@@ -120,8 +120,8 @@ class TestCorporateIdentityTemplateList(ERP5TypeTestCase):
# http://snipplr.com/view/757/compare-two-pil-images-in-python/
# http://effbot.org/zone/pil-comparing-images.htm
# http://effbot.org/imagingbook/image.htm
image1
=
Image
.
open
(
cStringIO
.
String
IO
(
image_data_1
))
image2
=
Image
.
open
(
cStringIO
.
String
IO
(
image_data_2
))
image1
=
Image
.
open
(
Bytes
IO
(
image_data_1
))
image2
=
Image
.
open
(
Bytes
IO
(
image_data_2
))
# image can be converted into greyscale without transparency
h1
=
image1
.
histogram
()
...
...
bt5/erp5_payroll_l10n_fr/TestTemplateItem/portal_components/test.erp5.testSimplifiedPayslipReport.py
View file @
0ef616f2
...
...
@@ -28,7 +28,7 @@
from
Products.ERP5Type.tests.ERP5TypeTestCase
import
ERP5TypeTestCase
from
DateTime
import
DateTime
from
PIL
import
Image
import
cString
IO
from
io
import
Bytes
IO
import
math
import
os.path
from
Products.Localizer.itools.i18n.accept
import
AcceptLanguage
...
...
@@ -57,8 +57,8 @@ class TestSimplifiedPayslipReport(ERP5TypeTestCase):
# http://snipplr.com/view/757/compare-two-pil-images-in-python/
# http://effbot.org/zone/pil-comparing-images.htm
# http://effbot.org/imagingbook/image.htm
image1
=
Image
.
open
(
cStringIO
.
String
IO
(
image_data_1
))
image2
=
Image
.
open
(
cStringIO
.
String
IO
(
image_data_2
))
image1
=
Image
.
open
(
Bytes
IO
(
image_data_1
))
image2
=
Image
.
open
(
Bytes
IO
(
image_data_2
))
# image can be converted into greyscale without transparency
h1
=
image1
.
histogram
()
...
...
product/ERP5OOo/tests/testOOoDynamicStyle.py
View file @
0ef616f2
...
...
@@ -29,11 +29,12 @@
import
os
import
unittest
from
six.moves
import
cStringIO
as
String
IO
from
io
import
Bytes
IO
from
zipfile
import
ZipFile
from
Products.ERP5Type.tests.utils
import
FileUpload
from
Products.ERP5Type.tests.ERP5TypeTestCase
import
ERP5TypeTestCase
from
Products.ERP5Type.tests.utils
import
DummyLocalizer
from
Products.ERP5Type.Utils
import
bytes2str
from
Products.ERP5OOo.tests.utils
import
Validator
from
Products.ERP5OOo.OOoUtils
import
OOoBuilder
...
...
@@ -126,7 +127,7 @@ return getattr(context, "%s_%s" % (parameter, current_language))
self
.
assertEqual
(
200
,
response
.
getStatus
())
ooo_builder
=
OOoBuilder
(
response
.
getBody
())
styles_xml_body
=
ooo_builder
.
extract
(
'styles.xml'
)
styles_xml_body
=
bytes2str
(
ooo_builder
.
extract
(
'styles.xml'
)
)
self
.
assertTrue
(
len
(
styles_xml_body
)
>
0
)
# 'Style sheet ja' text is in the odt document header,
# and the header is in the 'styles.xml'.
...
...
@@ -139,7 +140,7 @@ return getattr(context, "%s_%s" % (parameter, current_language))
response
=
self
.
publish
(
'/'
+
self
.
getPortal
().
Dynamic_viewAsOdt
.
absolute_url
(
1
))
self
.
_validate
(
response
.
getBody
())
ooo_builder
=
OOoBuilder
(
response
.
getBody
())
styles_xml_body
=
ooo_builder
.
extract
(
'styles.xml'
)
styles_xml_body
=
bytes2str
(
ooo_builder
.
extract
(
'styles.xml'
)
)
self
.
assertTrue
(
styles_xml_body
.
find
(
'Style sheet en'
)
>
0
)
# 3. test a fail case, reset a not existed stylesheet
...
...
@@ -152,7 +153,7 @@ return getattr(context, "%s_%s" % (parameter, current_language))
self
.
getPortal
().
Localizer
.
changeLanguage
(
'en'
)
response
=
self
.
publish
(
'/'
+
self
.
getPortal
().
Dynamic_viewAsOdt
.
absolute_url
(
1
))
# then, it is not a zip stream
self
.
assertFalse
(
response
.
getBody
().
startswith
(
'PK'
))
self
.
assertFalse
(
response
.
getBody
().
startswith
(
b
'PK'
))
self
.
assertEqual
(
500
,
response
.
getStatus
())
...
...
@@ -179,7 +180,7 @@ return getattr(context, "%s_%s" % (parameter, current_language))
response
.
getHeader
(
'content-disposition'
))
self
.
_validate
(
response
.
getBody
())
ooo_builder
=
OOoBuilder
(
response
.
getBody
())
styles_xml_body
=
ooo_builder
.
extract
(
'styles.xml'
)
styles_xml_body
=
bytes2str
(
ooo_builder
.
extract
(
'styles.xml'
)
)
self
.
assertTrue
(
len
(
styles_xml_body
)
>
0
)
self
.
assertTrue
(
styles_xml_body
.
find
(
'Style sheet ja'
)
>
0
)
...
...
@@ -191,7 +192,7 @@ return getattr(context, "%s_%s" % (parameter, current_language))
self
.
assertEqual
(
200
,
response
.
getStatus
())
self
.
_validate
(
response
.
getBody
())
ooo_builder
=
OOoBuilder
(
response
.
getBody
())
styles_xml_body
=
ooo_builder
.
extract
(
'styles.xml'
)
styles_xml_body
=
bytes2str
(
ooo_builder
.
extract
(
'styles.xml'
)
)
self
.
assertTrue
(
len
(
styles_xml_body
)
>
0
)
self
.
assertTrue
(
styles_xml_body
.
find
(
'Style sheet en'
)
>
0
)
...
...
@@ -200,7 +201,7 @@ return getattr(context, "%s_%s" % (parameter, current_language))
Static_viewAsOdt
.
doSettings
(
request
,
title
=
''
,
xml_file_id
=
'content.xml'
,
ooo_stylesheet
=
'NotFound_getODTStyleSheet'
,
script_name
=
''
)
response
=
self
.
publish
(
'/'
+
self
.
getPortal
().
Static_viewAsOdt
.
absolute_url
(
1
))
self
.
assertFalse
(
response
.
getBody
().
startswith
(
'PK'
))
self
.
assertFalse
(
response
.
getBody
().
startswith
(
b
'PK'
))
self
.
assertEqual
(
500
,
response
.
getStatus
())
def
test_include_img
(
self
):
...
...
@@ -237,14 +238,14 @@ return getattr(context, "%s_%s" % (parameter, current_language))
response
.
getHeader
(
'content-type'
).
split
(
';'
)[
0
])
self
.
assertEqual
(
'attachment; filename="Base_viewIncludeImageAsOdt.odt"'
,
response
.
getHeader
(
'content-disposition'
))
cs
=
String
IO
()
cs
=
Bytes
IO
()
cs
.
write
(
body
)
zip_document
=
ZipFile
(
cs
)
picture_list
=
filter
(
lambda
x
:
"Pictures"
in
x
.
filename
,
zip_document
.
infolist
())
self
.
assertNotEqual
([],
picture_list
)
manifest
=
zip_document
.
read
(
'META-INF/manifest.xml'
)
content
=
zip_document
.
read
(
'content.xml'
)
manifest
=
bytes2str
(
zip_document
.
read
(
'META-INF/manifest.xml'
)
)
content
=
bytes2str
(
zip_document
.
read
(
'content.xml'
)
)
for
picture
in
picture_list
:
self
.
assertIn
(
picture
.
filename
,
manifest
)
self
.
assertIn
(
picture
.
filename
,
content
)
...
...
product/Zelenium/tests/test_zuite.py
View file @
0ef616f2
...
...
@@ -112,9 +112,9 @@ class ZuiteTests( unittest.TestCase ):
return
old
def
_verifyArchive
(
self
,
bits
,
contents
):
import
String
IO
from
io
import
Bytes
IO
import
zipfile
stream
=
StringIO
.
String
IO
(
bits
)
stream
=
Bytes
IO
(
bits
)
archive
=
zipfile
.
ZipFile
(
stream
,
'r'
)
names
=
list
(
archive
.
namelist
()
)
...
...
@@ -139,9 +139,9 @@ class ZuiteTests( unittest.TestCase ):
def
_verifyManifest
(
self
,
bits
,
name
,
contents
):
import
String
IO
from
io
import
Bytes
IO
import
zipfile
stream
=
StringIO
.
String
IO
(
bits
)
stream
=
Bytes
IO
(
bits
)
archive
=
zipfile
.
ZipFile
(
stream
,
'r'
)
manifest
=
filter
(
None
,
archive
.
read
(
name
).
split
(
'
\
n
'
)
)
...
...
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