summaryrefslogtreecommitdiff
path: root/openerp/modules/module.py
diff options
context:
space:
mode:
Diffstat (limited to 'openerp/modules/module.py')
-rw-r--r--openerp/modules/module.py21
1 files changed, 13 insertions, 8 deletions
diff --git a/openerp/modules/module.py b/openerp/modules/module.py
index b9a77f5f7f3..f4639ccc886 100644
--- a/openerp/modules/module.py
+++ b/openerp/modules/module.py
@@ -22,6 +22,8 @@
import functools
import imp
+import importlib
+import inspect
import itertools
import logging
import os
@@ -366,23 +368,26 @@ def adapt_version(version):
return version
def get_test_modules(module):
- """ Return a list of module for the addons potentialy containing tests to
+ """ Return a list of module for the addons potentially containing tests to
feed unittest2.TestLoader.loadTestsFromModule() """
# Try to import the module
- module = 'openerp.addons.' + module + '.tests'
+ modpath = 'openerp.addons.' + module
try:
- __import__(module)
+ mod = importlib.import_module('.tests', modpath)
except Exception, e:
# If module has no `tests` sub-module, no problem.
if str(e) != 'No module named tests':
_logger.exception('Can not `import %s`.', module)
return []
- # include submodules too
- result = [mod_obj for name, mod_obj in sys.modules.iteritems()
- if mod_obj # mod_obj can be None
- if name.startswith(module)
- if re.search(r'test_\w+$', name)]
+ if hasattr(mod, 'fast_suite') or hasattr(mod, 'checks'):
+ _logger.warn(
+ "Found deprecated fast_suite or checks attribute in test module "
+ "%s. These have no effect in or after version 8.0.",
+ mod.__name__)
+
+ result = [mod_obj for name, mod_obj in inspect.getmembers(mod, inspect.ismodule)
+ if name.startswith('test_')]
return result
# Use a custom stream object to log the test executions.