unittest: Calling tests in liner number order

André andre.roberge at gmail.com
Sat May 24 09:22:27 EDT 2008


On May 24, 10:12 am, Roy Smith <r... at panix.com> wrote:
> In article
> <84ff733a-e364-437d-9b5d-d8bb14cc6... at m73g2000hsh.googlegroups.com>,
>  John Roth <johnro... at gmail.com> wrote:
>
> > > Does the following patch has a chance of being introduced in the
> > > standard python distribution?
>
> > I certainly hope not!
>
> I think you're being overly negative here.  Antoon went to the trouble to
> read the sources and post a diff.  At the very least, he deserves a more
> polite response.
>
> But, more than that, I think Antoon's idea has some merit.  I understand
> that the mantra in unit testing is that the tests should be able to be run
> in any order.  Still, it's the job of a library package to make it easy to
> do things, not to enforce policy.  If somebody (for whatever reason) has a
> need to run their tests in a certain order, why is it our job to make it
> hard for them to do that?
>
> In fact, unittest.defaultTestLoader *already* sorts the tests into
> alphabetical order by their name.  So, if somebody wanted to get the tests
> run in order, they could just name their tests "test0001", "test0002", etc.
> In fact, I've done that in the past when I had some (long forgotten) reason
> why I wanted to run a bunch of things in order.  Allowing the tests to be
> sorted by line number order instead of by name just makes it a little
> easier to do the same thing.
>
> If somebody wants that functionality, and is willing to put in the effort
> to write the code to do it, and contribute that back to the community, I
> don't see any reason why it shouldn't be considered.  It would have to be
> done in a way that doesn't change the current behavior (perhaps by shipping
> a subclass of TestLoader which users could use instead of the default).
> I'm not saying that we *need* to include it, just that it's not such a bad
> idea that it deserves responses like "I certainly hope not!"

I totally agree.

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

André



More information about the Python-list mailing list