Commit 3592dd40 authored by Arnaud Fontaine's avatar Arnaud Fontaine

ZODB Components: Live Tests could only be ran once.

reload(), which should be called only for filesystem tests, was called for
ZODB Components. So on the first execution, sys.modules was updated with a new
instance of the module whereas the module in erp5.component.test stayed the
same. On the second execution, reload() failed it checks whether
sys.modules[MODULE] == erp5.component.test.MODULE.
parent b29c3d54
...@@ -197,7 +197,8 @@ class ERP5TypeTestReLoader(ERP5TypeTestLoader): ...@@ -197,7 +197,8 @@ class ERP5TypeTestReLoader(ERP5TypeTestLoader):
If the module is not a ZODB Component, then reload it to consider If the module is not a ZODB Component, then reload it to consider
modifications on the filesystem modifications on the filesystem
""" """
if not isinstance(module, ComponentDynamicPackage): if not isinstance(getattr(module, '__loader__', None),
ComponentDynamicPackage):
reload(module) reload(module)
return super(ERP5TypeTestReLoader, self).loadTestsFromModule(module) return super(ERP5TypeTestReLoader, self).loadTestsFromModule(module)
...@@ -206,7 +207,8 @@ class ERP5TypeTestReLoader(ERP5TypeTestLoader): ...@@ -206,7 +207,8 @@ class ERP5TypeTestReLoader(ERP5TypeTestLoader):
# Do not reload ERP5TypeTestCase because we patch it nor ZODB Test # Do not reload ERP5TypeTestCase because we patch it nor ZODB Test
# Component as it is reset upon modification anyway # Component as it is reset upon modification anyway
if (testCaseClass is not ERP5TypeTestCase and if (testCaseClass is not ERP5TypeTestCase and
not isinstance(testModule, ComponentDynamicPackage)): not isinstance(getattr(testModule, '__loader__', None),
ComponentDynamicPackage)):
testModule = reload(testModule) testModule = reload(testModule)
testCaseClass = getattr(testModule, testCaseClass.__name__) testCaseClass = getattr(testModule, testCaseClass.__name__)
return ERP5TypeTestLoader.loadTestsFromTestCase(self, testCaseClass) return ERP5TypeTestLoader.loadTestsFromTestCase(self, testCaseClass)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment