> > The *primary* purpose of doctests are to be executable examples. When > you write documentation, including example code is the most natural > thing in the world. doctest lets you execute those examples, to ensure > that they work. They're certainly not meant as an exhaustive test of > every single feature in the program, but as *documentation* that > happens to also work as tests. > > Unit tests can be a little heavyweight, but they're designed for > exhaustive tests of the *entire* program, not just the parts with > user-documentation. You should write whitebox tests, not just blackbox > tests. That means don't just write tests for the published interface, > but write tests for the unpublished internal details as well. >
So, the gist is write tests for everything and the "external testing" should be handled by unit tests and the "internal testing" by doctests. Is that correct? > > E.g. if your function has special processing to deal with lists of > strings, then you need a test for input that is a list of strings. But > it's not necessary to document that fact in the doc string. What do the > users care that your function calls a special subroutine to deal with > lists of strings? So it would be inappropriate to draw attention to > this fact with a doctest. > > Doctests don't just execute themselves. If your developers, junior or > otherwise, don't know about the tests, don't keep the tests up to date, > and don't run the tests, then it doesn't matter what testing framework > you use. > Point taken....... > > Doctests and unittests are complementary. They work well together. In > fact, the unittest module can even execute doctests. > > This I didn't know this. I will have to do more investigation about this today. I did find that the Django doctest's were kind of limiting (at the documentation that I read). This opens up more possibilities to unify my tests. Thanks Steven for the pointers
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor