summaryrefslogtreecommitdiff
path: root/openerp/modules/module.py
diff options
context:
space:
mode:
authorXavier Morel <xmo@openerp.com>2014-02-17 16:58:30 +0100
committerXavier Morel <xmo@openerp.com>2014-02-17 16:58:30 +0100
commit9a22d42b8b0612b11bca7d16655946e51cf3ce92 (patch)
tree4e8d5ceff3802e87814bc9f229d134eab01cbeb2 /openerp/modules/module.py
parent0834a5ba49dbb97e9c1dce0566730aa5d5282037 (diff)
[IMP] unwrap tests suites during module loading, prepare for storing/filtering attributes
bzr revid: xmo@openerp.com-20140217155830-dcacx7qvyf7i0i4m
Diffstat (limited to 'openerp/modules/module.py')
-rw-r--r--openerp/modules/module.py23
1 files changed, 18 insertions, 5 deletions
diff --git a/openerp/modules/module.py b/openerp/modules/module.py
index a332d0ba804..18d26945d76 100644
--- a/openerp/modules/module.py
+++ b/openerp/modules/module.py
@@ -20,15 +20,13 @@
#
##############################################################################
-import base64
import imp
import itertools
import logging
import os
import re
import sys
-import types
-from cStringIO import StringIO
+import unittest
from os.path import join as opj
import unittest2
@@ -365,8 +363,8 @@ def run_unit_tests(module_name, dbname):
mods = get_test_modules(module_name)
r = True
for m in mods:
- suite = unittest2.TestSuite()
- suite.addTests(unittest2.TestLoader().loadTestsFromModule(m))
+ tests = unwrap_suite(unittest2.TestLoader().loadTestsFromModule(m))
+ suite = unittest2.TestSuite(tests)
_logger.info('module %s: running test %s.', module_name, m.__name__)
result = unittest2.TextTestRunner(verbosity=2, stream=TestStream()).run(suite)
@@ -376,4 +374,19 @@ def run_unit_tests(module_name, dbname):
current_test = None
return r
+def unwrap_suite(test):
+ if isinstance(test, unittest.TestCase):
+ yield test
+ return
+
+ subtests = list(test)
+ # custom test suite (no test cases)
+ if not len(subtests):
+ yield test
+ return
+
+ for item in itertools.chain.from_iterable(
+ itertools.imap(unwrap_suite, subtests)):
+ yield item
+
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: