replacing __dict__ with an OrderedDict
lie.1296 at gmail.com
Fri Jan 6 12:01:44 EST 2012
On 01/07/2012 12:36 AM, Ulrich Eckhardt wrote:
> Am 06.01.2012 12:43, schrieb Lie Ryan:
>> On 01/06/2012 08:48 PM, Ulrich Eckhardt wrote:
>>> The topic explains pretty much what I'm trying to do under Python
>>> 2.7. 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, 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 fully understand your issue, and I stand by my opinion. I believe
you're misunderstanding the nature of your problem, your issue is not
that you want a customized test order execution, but you want a
customized view of the test result.
That unittest executes its tests in alphabetical order is implementation
detail for a very good reason, and good unittest practice dictates that
execution order should never be defined (some even argued that the
execution order should be randomized). If the test runner turns out to
execute tests concurrently, that should not cause problems for a
well-designed test. Displaying the test results in a more convenient
order for viewing is what you really wanted in 99.99% of the cases.
> > 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.
Fun and easier, perhaps. Except that it solves the wrong problem.
More information about the Python-list