| 45 | | if hasattr(app_module, 'suite'): |
|---|
| 46 | | suite.addTest(app_module.suite()) |
|---|
| | 45 | if app_module.__file__.endswith(('/models/__init__.py', '/models/__init__.pyc')): |
|---|
| | 46 | from types import ModuleType |
|---|
| | 47 | import os.path |
|---|
| | 48 | app_locals = [getattr(app_module, x) for x in dir(app_module)] |
|---|
| | 49 | app_dirname = os.path.dirname(app_module.__file__) |
|---|
| | 50 | submodules = [x for x in app_locals |
|---|
| | 51 | if isinstance(x, ModuleType) |
|---|
| | 52 | and os.path.dirname(x.__file__) == app_dirname] |
|---|
| 48 | | suite.addTest(unittest.defaultTestLoader.loadTestsFromModule(app_module)) |
|---|
| 49 | | try: |
|---|
| 50 | | suite.addTest(doctest.DocTestSuite(app_module, |
|---|
| 51 | | checker=doctestOutputChecker, |
|---|
| 52 | | runner=DocTestRunner)) |
|---|
| 53 | | except ValueError: |
|---|
| 54 | | # No doc tests in models.py |
|---|
| 55 | | pass |
|---|
| 56 | | |
|---|
| | 54 | submodules = [] |
|---|
| | 55 | for module in [app_module] + submodules: |
|---|
| | 56 | if hasattr(module, 'suite'): |
|---|
| | 57 | suite.addTest(module.suite()) |
|---|
| | 58 | else: |
|---|
| | 59 | suite.addTest(unittest.defaultTestLoader.loadTestsFromModule(module)) |
|---|
| | 60 | try: |
|---|
| | 61 | suite.addTest(doctest.DocTestSuite(module, |
|---|
| | 62 | checker=doctestOutputChecker, |
|---|
| | 63 | runner=DocTestRunner)) |
|---|
| | 64 | except ValueError: |
|---|
| | 65 | # No doc tests in models.py |
|---|
| | 66 | pass |
|---|
| | 67 | |
|---|