﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
6143	provide doctest build helper	Antti Kaihola	nobody	"I suggest a tiny refactoring to the {{{django.test.simple}}} module: extract the {{{doctest.DocTestSuite()}}} call to its own function and use that in {{{build_suite()}}} twice.

This provides two benefits:

 * DRY in {{{django.test.simple}}}
 * doctest suite creation shortcut for {{{suite()}}} function in {{{models.py}}} or {{{tests.py}}}

Currently to include a doctest for an arbitrary module in the custom test suite, one must do:

{{{
from unittest import TestSuite
from django.test import _doctest as doctest
from django.test.simple import doctestOutputChecker
from django.test.testcases import DocTestRunner
import mymodule

def suite()
    suite = TestSuite()
    suite.addTest(doctest.DocTestSuite(
        mymodule,
        checker=doctestOutputChecker,
        runner=DocTestRunner))
    return suite
}}}

This refactoring simplifies the above to just:

{{{
from unittest import TestSuite
from django.test.simple import build_doctest_suite
import mymodule

def suite()
    suite = TestSuite()
    suite.addTest(build_doctest_suite(mymodule))
    return suite
}}}
"		closed	Testing framework	dev		wontfix			Design decision needed	0	0	0	0	0	0
