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
Levin Zimmermann
erp5
Commits
cac7d92f
Commit
cac7d92f
authored
Oct 25, 2022
by
Kazuhiko Shiozaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
py2/py3: define ERP5Type.Utils.cmp.
parent
b6db9aeb
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
1 deletion
+22
-1
product/ERP5Type/Utils.py
product/ERP5Type/Utils.py
+16
-1
product/ERP5Type/tests/testERP5Type.py
product/ERP5Type/tests/testERP5Type.py
+6
-0
No files found.
product/ERP5Type/Utils.py
View file @
cac7d92f
...
...
@@ -29,7 +29,6 @@
# Required modules - some modules are imported later to prevent circular deadlocks
from
__future__
import
absolute_import
from
past.builtins
import
cmp
from
six
import
int2byte
as
chr
from
six
import
string_types
as
basestring
from
six.moves
import
xrange
...
...
@@ -125,6 +124,22 @@ from Products.ERP5Type.Globals import get_request
from
.Accessor.TypeDefinition
import
type_definition
from
.Accessor.TypeDefinition
import
list_types
if
six
.
PY3
:
def
cmp
(
a
,
b
):
try
:
return
(
a
>
b
)
-
(
a
<
b
)
except
TypeError
:
if
a
is
None
:
return
-
1
elif
b
is
None
:
return
1
type_a
=
''
if
isinstance
(
a
,
(
int
,
float
))
else
type
(
a
).
__name__
type_b
=
''
if
isinstance
(
b
,
(
int
,
float
))
else
type
(
b
).
__name__
return
(
type_a
>
type_b
)
-
(
type_a
<
type_b
)
else
:
import
__builtin__
cmp
=
__builtin__
.
cmp
#####################################################
# Generic sort method
#####################################################
...
...
product/ERP5Type/tests/testERP5Type.py
View file @
cac7d92f
...
...
@@ -38,6 +38,7 @@ from Acquisition import aq_base
from
Products.ERP5Type.tests.ERP5TypeTestCase
import
ERP5TypeTestCase
from
AccessControl.ZopeGuards
import
guarded_import
from
Products.ERP5Type.tests.utils
import
LogInterceptor
,
createZODBPythonScript
from
Products.ERP5Type.Utils
import
cmp
class
TestERP5Type
(
ERP5TypeTestCase
,
LogInterceptor
):
"""
...
...
@@ -290,6 +291,11 @@ class TestERP5Type(ERP5TypeTestCase, LogInterceptor):
self
.
assertIn
(
script
,
person
.
objectValues
())
self
.
assertNotIn
(
script
,
person
.
objectValues
(
portal_type
=
'Person'
))
def
test_cmp
(
self
):
self
.
assertEqual
(
cmp
(
None
,
0
),
-
1
)
self
.
assertEqual
(
cmp
(
None
,
''
),
-
1
)
self
.
assertEqual
(
cmp
(
0
,
''
),
-
1
)
def
test_suite
():
suite
=
unittest
.
TestSuite
()
suite
.
addTest
(
unittest
.
makeSuite
(
TestERP5Type
))
...
...
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