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
143
Merge Requests
143
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
7b4ce094
Commit
7b4ce094
authored
Oct 14, 2022
by
Kazuhiko Shiozaki
Committed by
Jérome Perrin
Dec 29, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
py2/py3: change fromlist for __import__() in Python 3.
parent
8bb44d5c
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
9 deletions
+15
-9
bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testERP5TypeInterfaces.py
...tem/portal_components/test.erp5.testERP5TypeInterfaces.py
+3
-2
product/ERP5Type/patches/DA.py
product/ERP5Type/patches/DA.py
+2
-1
product/ERP5Type/tests/runUnitTest.py
product/ERP5Type/tests/runUnitTest.py
+1
-1
product/ERP5Type/tests/testDynamicClassGeneration.py
product/ERP5Type/tests/testDynamicClassGeneration.py
+9
-5
No files found.
bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testERP5TypeInterfaces.py
View file @
7b4ce094
...
@@ -27,6 +27,7 @@
...
@@ -27,6 +27,7 @@
##############################################################################
##############################################################################
from
zope.interface.verify
import
verifyClass
from
zope.interface.verify
import
verifyClass
import
six
import
unittest
import
unittest
implements_tuple_list
=
[
implements_tuple_list
=
[
...
@@ -59,7 +60,7 @@ def makeTestMethod(import_tuple, interface):
...
@@ -59,7 +60,7 @@ def makeTestMethod(import_tuple, interface):
"""Common method which checks if documents implements interface"""
"""Common method which checks if documents implements interface"""
def
testMethod
(
self
):
def
testMethod
(
self
):
Klass
=
getattr
(
Klass
=
getattr
(
__import__
(
import_tuple
[
0
],
globals
(),
locals
(),
[
import_tuple
[
0
]]),
__import__
(
import_tuple
[
0
],
globals
(),
locals
(),
[
import_tuple
[
0
]]
if
six
.
PY2
else
[
'erp5'
]
),
import_tuple
[
1
])
import_tuple
[
1
])
import
Products.ERP5Type.interfaces
import
Products.ERP5Type.interfaces
...
@@ -68,7 +69,7 @@ def makeTestMethod(import_tuple, interface):
...
@@ -68,7 +69,7 @@ def makeTestMethod(import_tuple, interface):
except
AttributeError
:
except
AttributeError
:
InterfaceModuleName
=
'erp5.component.interface.%s'
%
interface
InterfaceModuleName
=
'erp5.component.interface.%s'
%
interface
Interface
=
getattr
(
Interface
=
getattr
(
__import__
(
InterfaceModuleName
,
globals
(),
locals
(),
[
InterfaceModuleName
]),
__import__
(
InterfaceModuleName
,
globals
(),
locals
(),
[
InterfaceModuleName
]
if
six
.
PY2
else
[
'erp5'
]
),
interface
)
interface
)
verifyClass
(
Interface
,
Klass
)
verifyClass
(
Interface
,
Klass
)
...
...
product/ERP5Type/patches/DA.py
View file @
7b4ce094
...
@@ -30,6 +30,7 @@ from Acquisition import aq_base, aq_parent
...
@@ -30,6 +30,7 @@ from Acquisition import aq_base, aq_parent
from
zLOG
import
LOG
,
INFO
,
ERROR
from
zLOG
import
LOG
,
INFO
,
ERROR
from
io
import
BytesIO
from
io
import
BytesIO
from
Products.ERP5Type
import
Permissions
from
Products.ERP5Type
import
Permissions
import
six
security
=
ClassSecurityInfo
()
security
=
ClassSecurityInfo
()
DA
.
security
=
security
DA
.
security
=
security
...
@@ -279,7 +280,7 @@ def getObjectMeta(original_function):
...
@@ -279,7 +280,7 @@ def getObjectMeta(original_function):
# imported, which is enough to use a ZODB Extension as a brain.
# imported, which is enough to use a ZODB Extension as a brain.
try
:
try
:
m
=
__import__
(
'erp5.component.extension.%s'
%
module
,
globals
(),
m
=
__import__
(
'erp5.component.extension.%s'
%
module
,
globals
(),
{},
'erp5.component.extension'
)
{},
[
'erp5.component.extension'
]
if
six
.
PY2
else
[
'erp5'
]
)
o
=
getattr
(
m
,
name
,
None
)
o
=
getattr
(
m
,
name
,
None
)
if
o
is
None
:
if
o
is
None
:
...
...
product/ERP5Type/tests/runUnitTest.py
View file @
7b4ce094
...
@@ -300,7 +300,7 @@ class ERP5TypeTestLoader(unittest.TestLoader):
...
@@ -300,7 +300,7 @@ class ERP5TypeTestLoader(unittest.TestLoader):
def
_importZodbTestComponent
(
self
,
name
):
def
_importZodbTestComponent
(
self
,
name
):
import
erp5.component.test
import
erp5.component.test
module
=
__import__
(
'erp5.component.test.'
+
name
,
module
=
__import__
(
'erp5.component.test.'
+
name
,
fromlist
=
[
'erp5.component.test'
],
fromlist
=
[
'erp5.component.test'
]
if
six
.
PY2
else
[
'erp5'
]
,
level
=
0
)
level
=
0
)
try
:
try
:
self
.
_test_component_ref_list
.
append
(
module
)
self
.
_test_component_ref_list
.
append
(
module
)
...
...
product/ERP5Type/tests/testDynamicClassGeneration.py
View file @
7b4ce094
...
@@ -1454,7 +1454,7 @@ class TestZodbModuleComponent(SecurityTestCase):
...
@@ -1454,7 +1454,7 @@ class TestZodbModuleComponent(SecurityTestCase):
def
afterSetUp
(
self
):
def
afterSetUp
(
self
):
self
.
_component_tool
=
self
.
portal
.
portal_components
self
.
_component_tool
=
self
.
portal
.
portal_components
self
.
_module
=
__import__
(
self
.
_document_class
.
_getDynamicModuleNamespace
(),
self
.
_module
=
__import__
(
self
.
_document_class
.
_getDynamicModuleNamespace
(),
fromlist
=
[
'erp5.component'
])
fromlist
=
[
'erp5.component'
]
if
six
.
PY2
else
[
'erp5'
]
)
self
.
_component_tool
.
reset
(
force
=
True
,
self
.
_component_tool
.
reset
(
force
=
True
,
reset_portal_type_at_transaction_boundary
=
True
)
reset_portal_type_at_transaction_boundary
=
True
)
...
@@ -1524,7 +1524,10 @@ class TestZodbModuleComponent(SecurityTestCase):
...
@@ -1524,7 +1524,10 @@ class TestZodbModuleComponent(SecurityTestCase):
if
expected_default_version
is
not
None
:
if
expected_default_version
is
not
None
:
top_module_name
=
self
.
_document_class
.
_getDynamicModuleNamespace
()
top_module_name
=
self
.
_document_class
.
_getDynamicModuleNamespace
()
top_module
=
__import__
(
top_module_name
,
level
=
0
,
fromlist
=
[
top_module_name
])
top_module
=
__import__
(
top_module_name
,
level
=
0
,
fromlist
=
[
top_module_name
]
if
six
.
PY2
else
[
'erp5'
])
# The module must be available in its default version
# The module must be available in its default version
self
.
assertHasAttribute
(
top_module
,
expected_default_version
)
self
.
assertHasAttribute
(
top_module
,
expected_default_version
)
...
@@ -1555,7 +1558,8 @@ class TestZodbModuleComponent(SecurityTestCase):
...
@@ -1555,7 +1558,8 @@ class TestZodbModuleComponent(SecurityTestCase):
module_name
=
self
.
_getComponentFullModuleName
(
module_name
)
module_name
=
self
.
_getComponentFullModuleName
(
module_name
)
module
=
__import__
(
module
=
__import__
(
module_name
,
module_name
,
fromlist
=
[
self
.
_document_class
.
_getDynamicModuleNamespace
()],
fromlist
=
[
self
.
_document_class
.
_getDynamicModuleNamespace
()]
if
six
.
PY2
else
[
'erp5'
],
level
=
0
)
level
=
0
)
self
.
assertIn
(
module_name
,
sys
.
modules
)
self
.
assertIn
(
module_name
,
sys
.
modules
)
return
module
return
module
...
@@ -2042,7 +2046,7 @@ def bar(*args, **kwargs):
...
@@ -2042,7 +2046,7 @@ def bar(*args, **kwargs):
self
.
assertModuleImportable
(
'erp5_version.%s'
%
imported_reference
)
self
.
assertModuleImportable
(
'erp5_version.%s'
%
imported_reference
)
top_module
=
__import__
(
top_module_name
,
level
=
0
,
top_module
=
__import__
(
top_module_name
,
level
=
0
,
fromlist
=
[
top_module_name
])
fromlist
=
[
top_module_name
]
if
six
.
PY2
else
[
'erp5'
]
)
self
.
_importModule
(
'erp5_version.%s'
%
imported_reference
)
self
.
_importModule
(
'erp5_version.%s'
%
imported_reference
)
...
@@ -2105,7 +2109,7 @@ def function_foo(*args, **kwargs):
...
@@ -2105,7 +2109,7 @@ def function_foo(*args, **kwargs):
top_module_name
=
self
.
_document_class
.
_getDynamicModuleNamespace
()
top_module_name
=
self
.
_document_class
.
_getDynamicModuleNamespace
()
top_module
=
__import__
(
top_module_name
,
level
=
0
,
top_module
=
__import__
(
top_module_name
,
level
=
0
,
fromlist
=
[
top_module_name
])
fromlist
=
[
top_module_name
]
if
six
.
PY2
else
[
'erp5'
]
)
self
.
_importModule
(
reference
)
self
.
_importModule
(
reference
)
module
=
getattr
(
top_module
,
reference
)
module
=
getattr
(
top_module
,
reference
)
...
...
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