[TIP] Building a unittest.TestCase from a doctest

Titus Brown titus at caltech.edu
Mon Dec 17 22:39:08 PST 2007


Hi folks,

both Noah and I have been trying to figure out how to load a doctest
into a unittest.TestCase.

In my situation, I would like to load doctests from
/over/there/module.py into a file 'test.py' that is loaded with other
unittest.TestCases, and have the doctest run together with the other
test cases.

There's already an API to load doctests into a unittest.TestSuite, but I
don't know how to get nose (for example) to run a test suite as a series
of test casese without using a plugin.

The kind of code I'm looking for would look like this:

---
test_run_doctests = doctest.LoadDoctestsFrom(module)
---

where test_run_doctests inherits from a unittest.TestCase.

Any thoughts?

thanks,
--titus



More information about the testing-in-python mailing list