Opened 11 years ago

Closed 11 years ago

#6143 closed (wontfix)

provide doctest build helper

Reported by: Antti Kaihola Owned by: nobody
Component: Testing framework Version: master
Severity: Keywords:
Cc: Triage Stage: Design decision needed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


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 or

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()
    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()
    return suite

Attachments (1)

test-simple-refactor.diff (1.8 KB) - added by Antti Kaihola 11 years ago.
suggested patch

Download all attachments as: .zip

Change History (3)

Changed 11 years ago by Antti Kaihola

Attachment: test-simple-refactor.diff added

suggested patch

comment:1 Changed 11 years ago by Simon G <dev@…>

Triage Stage: UnreviewedDesign decision needed

comment:2 Changed 11 years ago by Russell Keith-Magee

Resolution: wontfix
Status: newclosed

This seems like overkill to me. The repetition it removes isn't around a complex block of code that could be a serious maintenance problem - it's a single duplicated function call, with a common set of arguments. If you're building a custom test suite, I would argue that you should be explicitly making a decision on your Doctest arguments; the 'use the same defaults as Django' isn't a strong enough use case in my book.

Note: See TracTickets for help on using tickets.
Back to Top