|
Revision 284, 0.7 kB
(checked in by akaihola, 20 months ago)
|
|
[test] Refactored build_for_doctests()
|
| Line | |
|---|
| 1 | from unittest import TestSuite |
|---|
| 2 | from django.test.simple import doctest, doctestOutputChecker |
|---|
| 3 | from ambidjangolib.test.simple import DocTestRunner |
|---|
| 4 | |
|---|
| 5 | def build_for_doctests(*module_paths, **kwargs): |
|---|
| 6 | kwargs.setdefault('checker', doctestOutputChecker) |
|---|
| 7 | kwargs.setdefault('runner', DocTestRunner) |
|---|
| 8 | kwargs.setdefault('optionflags', doctest.REPORT_ONLY_FIRST_FAILURE) |
|---|
| 9 | def suite_func(): |
|---|
| 10 | suite = TestSuite() |
|---|
| 11 | for module_path in module_paths: |
|---|
| 12 | module = __import__(module_path) |
|---|
| 13 | for submodule_name in module_path.split('.')[1:]: |
|---|
| 14 | module = getattr(module, submodule_name) |
|---|
| 15 | suite.addTest(doctest.DocTestSuite(module, **kwargs)) |
|---|
| 16 | return suite |
|---|
| 17 | return suite_func |
|---|