[TIP] Doctest or unitest?

Andrew Bennetts andrew-tip at puzzling.org
Wed Mar 7 17:28:43 PST 2007


Benji York wrote:
> Andrew Bennetts wrote:
> >- It's harder to name and talk about a specific failing test case when 
> >your test
> >  case is example 27, about, oh, half-way down foo-feature.txt, compared to
> >  "FooTestCase.test_feature_with_all_knobs_turned_off".
> 
> For reference, the zope.testing test runner gives you the filename and 
> line number of test failures, so specifying the exact location of the 
> failing test is pretty easy.  I would expect other test runners could 
> implement that easily.

Sure.  Having the right line number (as 2.4 doctest seems to report) helps.

Line numbers are less convenient and human-friendly than a name like
"test_foo_with_empty_set".  This is particularly so when you want to compare
with tests in another branch, which is a fairly common situation (why is this
test failing on this branch but passing on trunk and Alice's branch?).  Line
numbers change between file revisions, whereas test method names change rarely.
The nearest you can get is typically "third example under the XYZ heading",
which is awkward to say, and I can't use ctags to navigate to.

Again, this is a fairly minor point, but minor irritations add up...

-Andrew.




More information about the testing-in-python mailing list