replacing __dict__ with an OrderedDict

Ulrich Eckhardt ulrich.eckhardt at
Fri Jan 6 08:36:25 EST 2012

Am 06.01.2012 12:43, schrieb Lie Ryan:
> On 01/06/2012 08:48 PM, Ulrich Eckhardt wrote:
>> Hi!
>> The topic explains pretty much what I'm trying to do under Python
>> 2.7[1]. The reason for this is that I want dir(SomeType) to show the
>> attributes in the order of their declaration. This in turn should
>> hopefully make unittest execute my tests in the order of their
>> declaration[2], so that the output becomes more readable and structured,
>> just as my test code (hopefully) is.
> IMO that's a futile effort, first, because as you already know, the test
> should not rely on the order. If you want the result to be printed in a
> certain order, that's a display issue, not testing order issue.

I'm not sure if you just -ahem- enjoy Usenet discussions, but please 
read the footnote that explains that I don't want to discuss this part 
and why you are actually wrong with your partial understanding of the 
issue. ;^)

 > I guess you would have better luck doing what you want by customizing
 > the TestResult or TestRunner.

True, perhaps, but doing it this way would be more fun and easier 
reusable in other cases where the default order is not desirable. I can 
also go and name the test functions test_000 to test_009 to get results 
quickly, if that was the only goal.



More information about the Python-list mailing list