Alex Rivera | Logout

Python - doctest vs. unittest

Asked 2008-12-12T01:50:19.310
170

I'm trying to get started with unit testing in Python and I was wondering if someone could explain the advantages and disadvantages of doctest and unittest.

What conditions would you use each for?

Edit
Report

1 Answer

51

I use unittest almost exclusively.

Once in a while, I'll put some stuff in a docstring that's usable by doctest.

95% of the test cases are unittest.

Why? I like keeping docstrings somewhat shorter and more to the point. Sometimes test cases help clarify a docstring. Most of the time, the application's test cases are too long for a docstring.

answered 2008-12-12T01:53:38.960

Your Answer