unittest, order of test execution

Yinon Ehrlich yinon.me at gmail.com
Tue Jan 27 04:33:06 EST 2009


> But I was wondering, *should* this test be separated into two unit
> tests, one for each function? On the face of it, it looks that's how it
> should be done.
>
> This, however, raises the question: what's the order of test execution
> in the unittest? And how to pass values between unit tests? Should I
> modify 'self' in unit test?

It's OK to run some tests in the same function.
When one of the asserts fails, following the traceback will lead you
straight to your problem.

The order of test execution is done by default by sorting the test
functions alphabetically.
You may disable the sort by setting self.sortTestMethodsUsing to None.
The simplest way to pass values between tests is to use the class it
(self).

  Yinon



More information about the Python-list mailing list