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
Binh
erp5
Commits
9240d498
Commit
9240d498
authored
Sep 05, 2014
by
Arnaud Fontaine
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ERP5TypeLiveTestCase: Remove FS reloader as ZODB Components should be used from now on.
parent
a306c7c6
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
57 deletions
+13
-57
product/ERP5Type/tests/ERP5TypeLiveTestCase.py
product/ERP5Type/tests/ERP5TypeLiveTestCase.py
+7
-49
product/ERP5Type/tests/runUnitTest.py
product/ERP5Type/tests/runUnitTest.py
+6
-8
No files found.
product/ERP5Type/tests/ERP5TypeLiveTestCase.py
View file @
9240d498
...
...
@@ -162,31 +162,10 @@ class ERP5TypeLiveTestCase(ERP5TypeTestCaseMixin):
from
Products.ERP5Type.dynamic.component_package
import
ComponentDynamicPackage
from
Products.ERP5Type.tests.runUnitTest
import
ERP5TypeTestLoader
class
ERP5Type
TestRe
Loader
(
ERP5TypeTestLoader
):
"""
ERP5Type test re-loader supports reloading test modules before
running them.
class
ERP5Type
LiveTest
Loader
(
ERP5TypeTestLoader
):
"""
ERP5Type Live Test loader which allows to load ZODB Components if any
"""
def
__init__
(
self
,
filter_test_list
=
()):
super
(
ERP5TypeTestReLoader
,
self
).
__init__
()
if
len
(
filter_test_list
):
# do not filter if no filter, otherwise no tests run
self
.
filter_test_list
=
filter_test_list
def
loadTestsFromNames
(
self
,
test_list
):
# ERP5TypeTestLoader is monkey-patched into unittest
# so we have to monkeypatch it in turn
if
self
.
filter_test_list
is
not
None
:
old_filter_test_list
=
ERP5TypeTestLoader
.
filter_test_list
ERP5TypeTestLoader
.
filter_test_list
=
self
.
filter_test_list
try
:
return
super
(
ERP5TypeTestReLoader
,
self
).
loadTestsFromNames
(
test_list
)
finally
:
# and undo the monkeypatch afterwards
if
self
.
filter_test_list
:
ERP5TypeTestLoader
.
filter_test_list
=
old_filter_test_list
def
loadTestsFromName
(
self
,
name
,
module
=
None
):
"""
Load the test from the given name from ZODB if it can be imported,
...
...
@@ -200,34 +179,13 @@ class ERP5TypeTestReLoader(ERP5TypeTestLoader):
fromlist
=
[
'erp5.component.test'
],
level
=
0
)
except
ImportError
:
pass
raise
else
:
module
=
erp5
.
component
.
test
return
super
(
ERP5Type
TestRe
Loader
,
self
).
loadTestsFromName
(
name
,
return
super
(
ERP5Type
LiveTest
Loader
,
self
).
loadTestsFromName
(
name
,
module
)
def
loadTestsFromModule
(
self
,
module
):
"""
If the module is not a ZODB Component, then reload it to consider
modifications on the filesystem
"""
if
not
isinstance
(
getattr
(
module
,
'__loader__'
,
None
),
ComponentDynamicPackage
):
reload
(
module
)
return
super
(
ERP5TypeTestReLoader
,
self
).
loadTestsFromModule
(
module
)
def
loadTestsFromTestCase
(
self
,
testCaseClass
):
testModule
=
sys
.
modules
[
testCaseClass
.
__module__
]
# Do not reload ERP5TypeTestCase because we patch it nor ZODB Test
# Component as it is reset upon modification anyway
if
(
testCaseClass
is
not
ERP5TypeTestCase
and
not
isinstance
(
getattr
(
testModule
,
'__loader__'
,
None
),
ComponentDynamicPackage
)):
testModule
=
reload
(
testModule
)
testCaseClass
=
getattr
(
testModule
,
testCaseClass
.
__name__
)
return
ERP5TypeTestLoader
.
loadTestsFromTestCase
(
self
,
testCaseClass
)
def
runLiveTest
(
test_list
,
verbosity
=
1
,
stream
=
None
,
**
kw
):
from
Products.ERP5Type.tests.runUnitTest
import
DebugTestResult
from
Products.ERP5Type.tests
import
backportUnittest
...
...
@@ -257,7 +215,7 @@ def runLiveTest(test_list, verbosity=1, stream=None, **kw):
run_only
=
kw
.
get
(
'run_only'
,
())
filter_test_list
=
[
re
.
compile
(
x
).
search
for
x
in
run_only
]
loader
=
ERP5Type
TestRe
Loader
(
filter_test_list
)
loader
=
ERP5Type
LiveTest
Loader
(
filter_test_list
)
suite
=
loader
.
loadTestsFromNames
(
test_list
)
output
=
stream
if
stream
is
None
:
...
...
product/ERP5Type/tests/runUnitTest.py
View file @
9240d498
...
...
@@ -270,13 +270,16 @@ else:
class
ERP5TypeTestLoader
(
unittest
.
TestLoader
):
"""Load test cases from the name passed on the command line.
"""
filter_test_list
=
None
_testMethodPrefix
=
'test'
testMethodPrefix
=
property
(
lambda
self
:
self
.
_testMethodPrefix
,
lambda
self
,
value
:
None
)
def
__init__
(
self
,
filter_test_list
=
()):
super
(
ERP5TypeTestLoader
,
self
).
__init__
()
self
.
filter_test_list
=
filter_test_list
def
loadTestsFromName
(
self
,
name
,
module
=
None
):
"""
This method is here for compatibility with old style arguments:
...
...
@@ -654,14 +657,9 @@ def runUnitTestList(test_list, verbosity=1, debug=0, run_only=None):
result = super(DebugTextTestRunner, self)._makeResult()
return DebugTestResult(result)
TestRunner = DebugTextTestRunner
loader = ERP5TypeTestLoader()
if run_only:
ERP5TypeTestLoader.filter_test_list = [re.compile(x).search for x in
run_only.split(',')]
loader = ERP5TypeTestLoader(
[re.compile(x).search for x in run_only.split(',')] if run_only else ())
suite = loader.loadTestsFromNames(test_list)
if run_only:
ERP5TypeTestLoader.filter_test_list = None
if node_pid_list is None:
result = suite()
...
...
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