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.

I've been toying around with metaclasses, trying to replace __dict__ directly, or using type() to construct the class, but either I hit read-only attributes or the changes seem to be ignored.

As additional thought (but I'm not there yet), I guess that if I want dir(some_object) to be ordered similarly, I will also have to perform some steps on instance creation, not only on class creation, right?

Thanks for any suggestions!

Uli


[1] I'm stuck with 2.x for now, from what I found it would be easier using 3.x.

[2] No, don't tell me that the tests should run in any order. It's not the case that my tests depend on each other, but if one basic test for the presence of an API fails, the elaborate tests using that API will obviously fail, too, and I just want to take the first test that fails and analyse that instead of guessing the point to start debugging from the N failed tests.
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to