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
Carlos Ramos Carreño
erp5
Commits
e9f3675d
Commit
e9f3675d
authored
Mar 28, 2024
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
testDynamicClassGeneration: more py3 fixes
parent
470997ff
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
16 deletions
+31
-16
product/ERP5Type/tests/testDynamicClassGeneration.py
product/ERP5Type/tests/testDynamicClassGeneration.py
+31
-16
No files found.
product/ERP5Type/tests/testDynamicClassGeneration.py
View file @
e9f3675d
...
@@ -2358,17 +2358,21 @@ _ = ZBigArray
...
@@ -2358,17 +2358,21 @@ _ = ZBigArray
module2_with_version
=
imported_module2_with_version
))
+
module2_with_version
=
imported_module2_with_version
))
+
component
.
getTextContent
())
component
.
getTextContent
())
must_be_in_cache_set
=
set
()
if
six
.
PY2
:
must_be_in_cache_set
.
add
(
namespace
)
self
.
_assertAstroidCacheContent
(
self
.
_assertAstroidCacheContent
(
must_be_in_cache_set
=
{
'%s'
%
namespace
}
,
must_be_in_cache_set
=
must_be_in_cache_set
,
must_not_be_in_cache_set
=
{
'%s.erp5_version'
%
namespace
,
must_not_be_in_cache_set
=
{
'%s.erp5_version'
%
namespace
,
imported_module1
,
imported_module1
,
imported_module1_with_version
,
imported_module1_with_version
,
imported_module2
,
imported_module2
,
imported_module2_with_version
})
imported_module2_with_version
})
component
.
checkSourceCode
()
component
.
checkSourceCode
()
if
six
.
PY2
:
must_be_in_cache_set
.
add
(
'%s.erp5_version'
%
namespace
)
self
.
_assertAstroidCacheContent
(
self
.
_assertAstroidCacheContent
(
must_be_in_cache_set
=
{
'%s'
%
namespace
,
must_be_in_cache_set
=
must_be_in_cache_set
,
'%s.erp5_version'
%
namespace
},
must_not_be_in_cache_set
=
{
imported_module1
,
must_not_be_in_cache_set
=
{
imported_module1
,
imported_module1_with_version
,
imported_module1_with_version
,
imported_module2
,
imported_module2
,
...
@@ -2469,7 +2473,7 @@ _ = ZBigArray
...
@@ -2469,7 +2473,7 @@ _ = ZBigArray
self
.
tic
()
self
.
tic
()
must_be_in_cache_set
=
set
()
must_be_in_cache_set
=
set
()
if
six
.
PY2
:
if
six
.
PY2
:
must_be_in_cache_set
.
add
(
str
(
namespace
)
)
must_be_in_cache_set
.
add
(
namespace
)
self
.
_assertAstroidCacheContent
(
self
.
_assertAstroidCacheContent
(
must_be_in_cache_set
=
must_be_in_cache_set
,
must_be_in_cache_set
=
must_be_in_cache_set
,
must_not_be_in_cache_set
=
{
'%s.erp5_version'
%
namespace
,
must_not_be_in_cache_set
=
{
'%s.erp5_version'
%
namespace
,
...
@@ -2760,7 +2764,7 @@ def foobar(self, a, b="portal_type"):
...
@@ -2760,7 +2764,7 @@ def foobar(self, a, b="portal_type"):
external_method
.
manage_setGuard
({
'guard_roles'
:
'Member'
})
external_method
.
manage_setGuard
({
'guard_roles'
:
'Member'
})
self
.
assertEqual
(
self
.
portal
.
TestPythonScript
(
a
=
'portal_ids'
),
'Id Tool'
)
self
.
assertEqual
(
self
.
portal
.
TestPythonScript
(
a
=
'portal_ids'
),
'Id Tool'
)
self
.
assertEqual
(
self
.
publish
(
base
+
'/portal_types/TestExternalMethod?'
self
.
assertEqual
(
self
.
publish
(
base
+
'/portal_types/TestExternalMethod?'
'a=Types Tool&b=type_class'
,
'ERP5TypeTestCase:'
).
getBody
(),
'TypesTool'
)
'a=Types Tool&b=type_class'
,
'ERP5TypeTestCase:'
).
getBody
(),
b
'TypesTool'
)
sm
=
getSecurityManager
()
sm
=
getSecurityManager
()
try
:
try
:
...
@@ -2785,7 +2789,7 @@ def foobar(self, a, b="portal_type"):
...
@@ -2785,7 +2789,7 @@ def foobar(self, a, b="portal_type"):
cfg
.
extensions
=
tempfile
.
mkdtemp
()
cfg
.
extensions
=
tempfile
.
mkdtemp
()
try
:
try
:
with
open
(
os
.
path
.
join
(
cfg
.
extensions
,
module
+
'.py'
),
"w"
)
as
f
:
with
open
(
os
.
path
.
join
(
cfg
.
extensions
,
module
+
'.py'
),
"w"
)
as
f
:
f
.
write
(
"foobar = lambda **kw: sorted(kw.ite
rite
ms())"
)
f
.
write
(
"foobar = lambda **kw: sorted(kw.items())"
)
self
.
assertEqual
(
external_method
(
z
=
1
,
a
=
0
),
[(
'a'
,
0
),
(
'z'
,
1
)])
self
.
assertEqual
(
external_method
(
z
=
1
,
a
=
0
),
[(
'a'
,
0
),
(
'z'
,
1
)])
finally
:
finally
:
shutil
.
rmtree
(
cfg
.
extensions
)
shutil
.
rmtree
(
cfg
.
extensions
)
...
@@ -2999,7 +3003,7 @@ from erp5.component.document.Person import Person
...
@@ -2999,7 +3003,7 @@ from erp5.component.document.Person import Person
from ITestPortalType import ITestPortalType
from ITestPortalType import ITestPortalType
import zope.interface
import zope.interface
zope.interface.implementer(ITestPortalType)
@
zope.interface.implementer(ITestPortalType)
class TestPortalType(Person):
class TestPortalType(Person):
def test42(self):
def test42(self):
return 42
return 42
...
@@ -3234,13 +3238,11 @@ class Test(ERP5TypeTestCase):
...
@@ -3234,13 +3238,11 @@ class Test(ERP5TypeTestCase):
"""
"""
Dummy mail host has already been set up when running tests
Dummy mail host has already been set up when running tests
"""
"""
pass
def _restoreMailHost(self):
def _restoreMailHost(self):
"""
"""
Dummy mail host has already been set up when running tests
Dummy mail host has already been set up when running tests
"""
"""
pass
def test_01_sampleTest(self):
def test_01_sampleTest(self):
self.assertEqual(0, 0)
self.assertEqual(0, 0)
...
@@ -3336,7 +3338,7 @@ class Test(ERP5TypeTestCase):
...
@@ -3336,7 +3338,7 @@ class Test(ERP5TypeTestCase):
reset_portal_type_at_transaction_boundary
=
True
)
reset_portal_type_at_transaction_boundary
=
True
)
output
=
runLiveTest
(
'testRunLiveTest'
)
output
=
runLiveTest
(
'testRunLiveTest'
)
expected_msg_re
=
re
.
compile
(
'Ran 2 tests.*FAILED
\
(
f
ailures=1
\
)
'
, re.DOTALL)
expected_msg_re
=
re
.
compile
(
r
'Ran 2 tests.*FAILED \
(
failures=1\
)
', re.DOTALL)
self.assertRegex(output, expected_msg_re)
self.assertRegex(output, expected_msg_re)
# Now try addCleanup
# Now try addCleanup
...
@@ -3412,18 +3414,29 @@ break_at_import()
...
@@ -3412,18 +3414,29 @@ break_at_import()
return
self
.
_component_tool
.
readTestOutput
()
return
self
.
_component_tool
.
readTestOutput
()
output
=
runLiveTest
(
'testRunLiveTestImportError'
)
output
=
runLiveTest
(
'testRunLiveTestImportError'
)
self
.
assertIn
(
'''
if
six
.
PY2
:
expected_output
=
'''
File "<portal_components/test.erp5.testRunLiveTestImportError>", line 4, in <module>
File "<portal_components/test.erp5.testRunLiveTestImportError>", line 4, in <module>
break_at_import()
break_at_import()
File "<portal_components/test.erp5.testRunLiveTestImportError>", line 3, in break_at_import
File "<portal_components/test.erp5.testRunLiveTestImportError>", line 3, in break_at_import
import non.existing.module # pylint:disable=import-error
import non.existing.module # pylint:disable=import-error
ImportError: No module named non.existing.module
ImportError: No module named non.existing.module
'''
,
output
)
'''
else
:
expected_output
=
'''
File "<portal_components/test.erp5.testRunLiveTestImportError>", line 4, in <module>
break_at_import()
File "<portal_components/test.erp5.testRunLiveTestImportError>", line 3, in break_at_import
import non.existing.module # pylint:disable=import-error
ModuleNotFoundError: No module named 'non'
'''
self
.
assertIn
(
expected_output
,
output
)
output
=
runLiveTest
(
'testDoesNotExist_import_error_because_module_does_not_exist'
)
output
=
runLiveTest
(
'testDoesNotExist_import_error_because_module_does_not_exist'
)
self
.
assertIn
(
if
six
.
PY2
:
"ImportError: No module named testDoesNotExist_import_error_because_module_does_not_exist"
,
expected_output
=
"ImportError: No module named testDoesNotExist_import_error_because_module_does_not_exist"
output
)
else
:
expected_output
=
"ModuleNotFoundError: No module named 'testDoesNotExist_import_error_because_module_does_not_exist'"
self
.
assertIn
(
expected_output
,
output
)
def
testERP5Broken
(
self
):
def
testERP5Broken
(
self
):
# Create a broken ghost object
# Create a broken ghost object
...
@@ -3661,6 +3674,8 @@ class TestZodbDocumentComponentReload(ERP5TypeTestCase):
...
@@ -3661,6 +3674,8 @@ class TestZodbDocumentComponentReload(ERP5TypeTestCase):
component
=
self
.
portal
.
portal_components
[
'document.erp5.BusinessProcess'
]
component
=
self
.
portal
.
portal_components
[
'document.erp5.BusinessProcess'
]
component
.
setTextContent
(
value
)
component
.
setTextContent
(
value
)
self
.
tic
()
self
.
tic
()
self
.
assertEqual
(
component
.
checkConsistency
(),
[])
self
.
assertEqual
(
component
.
getValidationState
(),
'validated'
)
def
testAsComposedDocumentCacheIsCorrectlyFlushed
(
self
):
def
testAsComposedDocumentCacheIsCorrectlyFlushed
(
self
):
component
=
self
.
portal
.
portal_components
[
'document.erp5.BusinessProcess'
]
component
=
self
.
portal
.
portal_components
[
'document.erp5.BusinessProcess'
]
...
...
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