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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Aaron Chen
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):
...
@@ -162,31 +162,10 @@ class ERP5TypeLiveTestCase(ERP5TypeTestCaseMixin):
from
Products.ERP5Type.dynamic.component_package
import
ComponentDynamicPackage
from
Products.ERP5Type.dynamic.component_package
import
ComponentDynamicPackage
from
Products.ERP5Type.tests.runUnitTest
import
ERP5TypeTestLoader
from
Products.ERP5Type.tests.runUnitTest
import
ERP5TypeTestLoader
class
ERP5Type
TestRe
Loader
(
ERP5TypeTestLoader
):
class
ERP5Type
LiveTest
Loader
(
ERP5TypeTestLoader
):
"""
ERP5Type test re-loader supports reloading test modules before
"""
running them.
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
):
def
loadTestsFromName
(
self
,
name
,
module
=
None
):
"""
"""
Load the test from the given name from ZODB if it can be imported,
Load the test from the given name from ZODB if it can be imported,
...
@@ -200,34 +179,13 @@ class ERP5TypeTestReLoader(ERP5TypeTestLoader):
...
@@ -200,34 +179,13 @@ class ERP5TypeTestReLoader(ERP5TypeTestLoader):
fromlist
=
[
'erp5.component.test'
],
fromlist
=
[
'erp5.component.test'
],
level
=
0
)
level
=
0
)
except
ImportError
:
except
ImportError
:
pass
raise
else
:
else
:
module
=
erp5
.
component
.
test
module
=
erp5
.
component
.
test
return
super
(
ERP5Type
TestRe
Loader
,
self
).
loadTestsFromName
(
name
,
return
super
(
ERP5Type
LiveTest
Loader
,
self
).
loadTestsFromName
(
name
,
module
)
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
):
def
runLiveTest
(
test_list
,
verbosity
=
1
,
stream
=
None
,
**
kw
):
from
Products.ERP5Type.tests.runUnitTest
import
DebugTestResult
from
Products.ERP5Type.tests.runUnitTest
import
DebugTestResult
from
Products.ERP5Type.tests
import
backportUnittest
from
Products.ERP5Type.tests
import
backportUnittest
...
@@ -257,7 +215,7 @@ def runLiveTest(test_list, verbosity=1, stream=None, **kw):
...
@@ -257,7 +215,7 @@ def runLiveTest(test_list, verbosity=1, stream=None, **kw):
run_only
=
kw
.
get
(
'run_only'
,
())
run_only
=
kw
.
get
(
'run_only'
,
())
filter_test_list
=
[
re
.
compile
(
x
).
search
filter_test_list
=
[
re
.
compile
(
x
).
search
for
x
in
run_only
]
for
x
in
run_only
]
loader
=
ERP5Type
TestRe
Loader
(
filter_test_list
)
loader
=
ERP5Type
LiveTest
Loader
(
filter_test_list
)
suite
=
loader
.
loadTestsFromNames
(
test_list
)
suite
=
loader
.
loadTestsFromNames
(
test_list
)
output
=
stream
output
=
stream
if
stream
is
None
:
if
stream
is
None
:
...
...
product/ERP5Type/tests/runUnitTest.py
View file @
9240d498
...
@@ -270,13 +270,16 @@ else:
...
@@ -270,13 +270,16 @@ else:
class
ERP5TypeTestLoader
(
unittest
.
TestLoader
):
class
ERP5TypeTestLoader
(
unittest
.
TestLoader
):
"""Load test cases from the name passed on the command line.
"""Load test cases from the name passed on the command line.
"""
"""
filter_test_list
=
None
_testMethodPrefix
=
'test'
_testMethodPrefix
=
'test'
testMethodPrefix
=
property
(
testMethodPrefix
=
property
(
lambda
self
:
self
.
_testMethodPrefix
,
lambda
self
:
self
.
_testMethodPrefix
,
lambda
self
,
value
:
None
)
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
):
def
loadTestsFromName
(
self
,
name
,
module
=
None
):
"""
"""
This method is here for compatibility with old style arguments:
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):
...
@@ -654,14 +657,9 @@ def runUnitTestList(test_list, verbosity=1, debug=0, run_only=None):
result = super(DebugTextTestRunner, self)._makeResult()
result = super(DebugTextTestRunner, self)._makeResult()
return DebugTestResult(result)
return DebugTestResult(result)
TestRunner = DebugTextTestRunner
TestRunner = DebugTextTestRunner
loader = ERP5TypeTestLoader()
loader = ERP5TypeTestLoader(
if run_only:
[re.compile(x).search for x in run_only.split(',')] if run_only else ())
ERP5TypeTestLoader.filter_test_list = [re.compile(x).search for x in
run_only.split(',')]
suite = loader.loadTestsFromNames(test_list)
suite = loader.loadTestsFromNames(test_list)
if run_only:
ERP5TypeTestLoader.filter_test_list = None
if node_pid_list is None:
if node_pid_list is None:
result = suite()
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