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
138
Merge Requests
138
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
Jobs
Commits
Open sidebar
nexedi
erp5
Commits
98bcae2a
Commit
98bcae2a
authored
Feb 09, 2024
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixup! core_test: py3
parent
1436f275
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
77 deletions
+35
-77
bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testBase.py
.../TestTemplateItem/portal_components/test.erp5.testBase.py
+6
-7
bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testERP5Type.py
...tTemplateItem/portal_components/test.erp5.testERP5Type.py
+27
-64
bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testQueryModule.py
...mplateItem/portal_components/test.erp5.testQueryModule.py
+1
-1
product/ERP5Type/mixin/temporary.py
product/ERP5Type/mixin/temporary.py
+1
-5
No files found.
bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testBase.py
View file @
98bcae2a
...
@@ -28,6 +28,7 @@
...
@@ -28,6 +28,7 @@
#
#
##############################################################################
##############################################################################
import
io
import
unittest
import
unittest
import
os
import
os
from
unittest
import
skip
from
unittest
import
skip
...
@@ -1050,14 +1051,12 @@ class TestBase(ERP5TypeTestCase, ZopeTestCase.Functional):
...
@@ -1050,14 +1051,12 @@ class TestBase(ERP5TypeTestCase, ZopeTestCase.Functional):
import
Products.ERP5Type
import
Products.ERP5Type
# tests that members can download files
# tests that members can download files
class
DummyFile
(
file
):
class
DummyFile
(
io
.
BytesIO
):
def
__init__
(
self
,
filename
):
filename
=
'dummy.txt'
self
.
filename
=
os
.
path
.
basename
(
filename
)
portal
=
self
.
portal
file
.
__init__
(
self
,
filename
)
portal
=
self
.
getPortal
()
organisation
=
portal
.
organisation_module
.
newContent
(
portal_type
=
'Organisation'
)
organisation
=
portal
.
organisation_module
.
newContent
(
portal_type
=
'Organisation'
)
file_document
=
organisation
.
newContent
(
portal_type
=
'Embedded File'
,
file_document
=
organisation
.
newContent
(
portal_type
=
'Embedded File'
,
file
=
DummyFile
(
Products
.
ERP5Type
.
__file__
),
file
=
DummyFile
(
b"data"
),
content_type
=
'text/plain'
)
content_type
=
'text/plain'
)
# login as a member
# login as a member
...
@@ -1073,7 +1072,7 @@ class TestBase(ERP5TypeTestCase, ZopeTestCase.Functional):
...
@@ -1073,7 +1072,7 @@ class TestBase(ERP5TypeTestCase, ZopeTestCase.Functional):
self
.
assertEqual
(
file_document
.
getData
(),
response
.
body
)
self
.
assertEqual
(
file_document
.
getData
(),
response
.
body
)
self
.
assertEqual
(
'text/plain'
,
self
.
assertEqual
(
'text/plain'
,
response
.
getHeader
(
'content-type'
).
split
(
';'
)[
0
])
response
.
getHeader
(
'content-type'
).
split
(
';'
)[
0
])
self
.
assertEqual
(
'attachment; filename="
%s"'
%
os
.
path
.
basename
(
Products
.
ERP5Type
.
__file__
)
,
self
.
assertEqual
(
'attachment; filename="
dummy.txt"'
,
response
.
getHeader
(
'content-disposition'
))
response
.
getHeader
(
'content-disposition'
))
def
test_getTypeBasedMethod
(
self
):
def
test_getTypeBasedMethod
(
self
):
...
...
bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testERP5Type.py
View file @
98bcae2a
...
@@ -26,10 +26,6 @@
...
@@ -26,10 +26,6 @@
#
#
##############################################################################
##############################################################################
try
:
from
ZODB._compat
import
cPickle
except
ImportError
:
# BBB: ZODB < 4
import
six.moves.cPickle
import
unittest
import
unittest
import
sys
import
sys
import
mock
import
mock
...
@@ -51,8 +47,11 @@ from AccessControl import Unauthorized
...
@@ -51,8 +47,11 @@ from AccessControl import Unauthorized
from
AccessControl.ZopeGuards
import
guarded_getattr
,
guarded_hasattr
from
AccessControl.ZopeGuards
import
guarded_getattr
,
guarded_hasattr
from
Products.ERP5Type.tests.utils
import
createZODBPythonScript
from
Products.ERP5Type.tests.utils
import
createZODBPythonScript
from
Products.ERP5Type.tests.utils
import
removeZODBPythonScript
from
Products.ERP5Type.tests.utils
import
removeZODBPythonScript
from
Products.ERP5Type
import
IS_ZOPE2
,
Permissions
from
Products.ERP5Type
import
Permissions
from
DateTime
import
DateTime
from
DateTime
import
DateTime
from
zodbpickle.pickle
import
PicklingError
import
six
class
PropertySheetTestCase
(
ERP5TypeTestCase
):
class
PropertySheetTestCase
(
ERP5TypeTestCase
):
"""Base test case class for property sheets tests.
"""Base test case class for property sheets tests.
...
@@ -330,7 +329,7 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
...
@@ -330,7 +329,7 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
portal
.
person_module
.
_setObject
(
o
.
getId
(),
aq_base
(
o
))
portal
.
person_module
.
_setObject
(
o
.
getId
(),
aq_base
(
o
))
try
:
try
:
self
.
commit
()
self
.
commit
()
except
six
.
moves
.
cPickle
.
PicklingError
:
except
PicklingError
:
self
.
abort
()
self
.
abort
()
else
:
else
:
self
.
fail
(
"No exception raised when storing explicitly a temp object"
self
.
fail
(
"No exception raised when storing explicitly a temp object"
...
@@ -3313,39 +3312,9 @@ def test_suite():
...
@@ -3313,39 +3312,9 @@ def test_suite():
add_tests
(
suite
,
ZPublisher
.
tests
.
testHTTPRangeSupport
)
add_tests
(
suite
,
ZPublisher
.
tests
.
testHTTPRangeSupport
)
import
ZPublisher.tests.testHTTPRequest
import
ZPublisher.tests.testHTTPRequest
if
IS_ZOPE2
:
# BBB Zope2
# ERP5 processes requests as utf-8 by default, but we adjust this test assuming that
# default is iso-8859-15
def
forceISO885915DefaultRequestCharset
(
method
):
def
wrapped
(
self
):
from
ZPublisher
import
HTTPRequest
as
module
old_encoding
=
module
.
default_encoding
module
.
default_encoding
=
'iso-8859-15'
try
:
return
method
(
self
)
finally
:
module
.
default_encoding
=
old_encoding
return
wrapped
HTTPRequestTests
=
ZPublisher
.
tests
.
testHTTPRequest
.
HTTPRequestTests
for
e
in
dir
(
HTTPRequestTests
):
if
e
.
startswith
(
'test_'
):
setattr
(
HTTPRequestTests
,
e
,
forceISO885915DefaultRequestCharset
(
getattr
(
HTTPRequestTests
,
e
)))
add_tests
(
suite
,
ZPublisher
.
tests
.
testHTTPRequest
)
add_tests
(
suite
,
ZPublisher
.
tests
.
testHTTPRequest
)
import
ZPublisher.tests.testHTTPResponse
import
ZPublisher.tests.testHTTPResponse
if
IS_ZOPE2
:
# BBB Zope2
# ERP5 forces utf-8 responses by default, but we adjust these tests so that they run
# with iso-8859-15 as default response charset
def
forceISO885915DefaultResponseCharset
(
method
):
def
wrapped
(
self
):
# here we can use this utility method which clean up at teardown
self
.
_setDefaultEncoding
(
'iso-8859-15'
)
return
method
(
self
)
return
wrapped
HTTPResponseTests
=
ZPublisher
.
tests
.
testHTTPResponse
.
HTTPResponseTests
for
e
in
dir
(
HTTPResponseTests
):
if
e
.
startswith
(
'test_'
):
setattr
(
HTTPResponseTests
,
e
,
forceISO885915DefaultResponseCharset
(
getattr
(
HTTPResponseTests
,
e
)))
add_tests
(
suite
,
ZPublisher
.
tests
.
testHTTPResponse
)
add_tests
(
suite
,
ZPublisher
.
tests
.
testHTTPResponse
)
import
ZPublisher.tests.testIterators
import
ZPublisher.tests.testIterators
...
@@ -3354,42 +3323,36 @@ def test_suite():
...
@@ -3354,42 +3323,36 @@ def test_suite():
import
ZPublisher.tests.testPostTraversal
import
ZPublisher.tests.testPostTraversal
add_tests
(
suite
,
ZPublisher
.
tests
.
testPostTraversal
)
add_tests
(
suite
,
ZPublisher
.
tests
.
testPostTraversal
)
if
IS_ZOPE2
:
# BBB Zope2
import
ZPublisher.tests.testPublish
# pylint:disable=no-name-in-module,import-error
import
ZPublisher.tests.testPublish
# pylint:disable=no-name-in-module,import-error
add_tests
(
suite
,
ZPublisher
.
tests
.
testPublish
)
add_tests
(
suite
,
ZPublisher
.
tests
.
testPublish
)
import
ZPublisher.tests.test_Converters
import
ZPublisher.tests.test_Converters
add_tests
(
suite
,
ZPublisher
.
tests
.
test_Converters
)
add_tests
(
suite
,
ZPublisher
.
tests
.
test_Converters
)
if
IS_ZOPE2
:
# BBB Zope2
import
ZPublisher.tests.test_WSGIPublisher
# XXX don't run test_WSGIPublisher for now because too many failures
# TestLoadApp tests are confused because running as a live test interfere with
pass
# transaction system. Aborting the transaction at beginning of test seems OK.
else
:
TestLoadApp_setUp
=
ZPublisher
.
tests
.
test_WSGIPublisher
.
TestLoadApp
.
setUp
import
ZPublisher.tests.test_WSGIPublisher
def
setUp
(
self
):
# TestLoadApp tests are confused because running as a live test interfere with
TestLoadApp_setUp
(
self
)
# transaction system. Aborting the transaction at beginning of test seems OK.
transaction
.
abort
()
TestLoadApp_setUp
=
ZPublisher
.
tests
.
test_WSGIPublisher
.
TestLoadApp
.
setUp
ZPublisher
.
tests
.
test_WSGIPublisher
.
TestLoadApp
.
setUp
=
setUp
def
setUp
(
self
):
add_tests
(
suite
,
ZPublisher
.
tests
.
test_WSGIPublisher
)
TestLoadApp_setUp
(
self
)
transaction
.
abort
()
ZPublisher
.
tests
.
test_WSGIPublisher
.
TestLoadApp
.
setUp
=
setUp
add_tests
(
suite
,
ZPublisher
.
tests
.
test_WSGIPublisher
)
import
ZPublisher.tests.test_mapply
import
ZPublisher.tests.test_mapply
add_tests
(
suite
,
ZPublisher
.
tests
.
test_mapply
)
add_tests
(
suite
,
ZPublisher
.
tests
.
test_mapply
)
if
IS_ZOPE2
:
# BBB Zope2
import
ZPublisher.tests.test_pubevents
import
ZPublisher.tests.testpubevents
# pylint:disable=no-name-in-module,import-error
add_tests
(
suite
,
ZPublisher
.
tests
.
test_pubevents
)
add_tests
(
suite
,
ZPublisher
.
tests
.
testpubevents
)
else
:
import
ZPublisher.tests.test_utils
import
ZPublisher.tests.test_pubevents
if
six
.
PY3
:
add_tests
(
suite
,
ZPublisher
.
tests
.
test_pubevents
)
# "fix_properties" does not work with ERP5Type patched properties
expectedFailure
(
ZPublisher
.
tests
.
test_utils
.
FixPropertiesTests
.
test_ulines
)
if
IS_ZOPE2
:
# BBB Zope2
expectedFailure
(
ZPublisher
.
tests
.
test_utils
.
FixPropertiesTests
.
test_ustring
)
pass
expectedFailure
(
ZPublisher
.
tests
.
test_utils
.
FixPropertiesTests
.
test_utext
)
else
:
expectedFailure
(
ZPublisher
.
tests
.
test_utils
.
FixPropertiesTests
.
test_utokens
)
import
ZPublisher.tests.test_utils
add_tests
(
suite
,
ZPublisher
.
tests
.
test_utils
)
add_tests
(
suite
,
ZPublisher
.
tests
.
test_utils
)
import
ZPublisher.tests.test_xmlrpc
import
ZPublisher.tests.test_xmlrpc
add_tests
(
suite
,
ZPublisher
.
tests
.
test_xmlrpc
)
add_tests
(
suite
,
ZPublisher
.
tests
.
test_xmlrpc
)
...
...
bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testQueryModule.py
View file @
98bcae2a
...
@@ -129,7 +129,7 @@ class TestQueryModule(ERP5TypeTestCase):
...
@@ -129,7 +129,7 @@ class TestQueryModule(ERP5TypeTestCase):
mfrom
,
mto
,
messageText
=
last_message
mfrom
,
mto
,
messageText
=
last_message
self
.
assertEqual
(
'owner_user@example.invalid'
,
mfrom
)
self
.
assertEqual
(
'owner_user@example.invalid'
,
mfrom
)
self
.
assertEqual
([
'question_user@example.invalid'
],
mto
)
self
.
assertEqual
([
'question_user@example.invalid'
],
mto
)
self
.
assert
True
(
'Query'
in
messageText
,
messageText
)
self
.
assert
In
(
b'Query'
,
messageText
)
def
test_suite
():
def
test_suite
():
...
...
product/ERP5Type/mixin/temporary.py
View file @
98bcae2a
...
@@ -26,11 +26,7 @@
...
@@ -26,11 +26,7 @@
#
#
##############################################################################
##############################################################################
try
:
from
zodbpickle.pickle
import
PicklingError
from
ZODB._compat
import
cPickle
PicklingError
=
cPickle
.
PicklingError
except
ImportError
:
# BBB: ZODB < 4
from
six.moves.cPickle
import
PicklingError
from
Acquisition
import
aq_base
from
Acquisition
import
aq_base
from
Products.ERP5Type.Accessor.Constant
import
PropertyGetter
as
\
from
Products.ERP5Type.Accessor.Constant
import
PropertyGetter
as
\
PropertyConstantGetter
PropertyConstantGetter
...
...
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