unittest: Calling tests in liner number order

John Roth johnroth1 at gmail.com
Sun May 25 09:17:58 EDT 2008


On May 24, 7:22 am, André <andre.robe... at gmail.com> wrote:

>
> I can't relate to anyone that want to oppose a change that would give
> more freedom to a programmer.
>
> André

Well, you can already do that. Or anything else you want. It's not all
that difficult to change the algorithms in the unittest package
_without_ patching the code. How to do it could be better documented,
granted.

For my major project (Python FIT) I've got my own test case extraction
mechanism that doesn't depend on patching the code. It lets me use any
name I want - that is, it doesn't depend on any kind of pattern match.
(It also avoids looking in subclasses for tests.) I find the naming
freedom to be quite useful in thinking about the test case.

I really don't care what the OP does in his own projects. My objection
is that, if it goes into the standard library, is that it passes a
signal that it's good practice to allow dependencies between tests. It
most definitely is _not_ good practice.

I like the technique of looking at the line numbers to get the
declaration order; it ought to be documented somewhere.

The proper place for this is either a recipe (
http://aspn.activestate.com/ASPN/Cookbook/Python/ ) or a note in the
documentation with a caveat that it's not good practice, but it may be
useful in some circumstances.

John Roth






More information about the Python-list mailing list