Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #18598
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'attributes': 0.05; '"""': 0.07; 'read-only': 0.07; 'unittest': 0.07; 'python': 0.08; '__name__': 0.09; 'readable': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; 'output': 0.10; 'def': 0.13; 'skip:f 30': 0.13; 'class,': 0.15; '"""return': 0.16; '"__main__":': 0.16; 'eckhardt': 0.16; 'name)': 0.16; 'received:dip.t-dialin.net': 0.16; 'received:t-dialin.net': 0.16; 'wrote:': 0.18; 'trying': 0.21; 'from:addr:web.de': 0.23; 'skip:m 30': 0.24; 'explains': 0.24; 'hopefully': 0.24; 'tests': 0.25; 'code': 0.25; "i'm": 0.26; 'import': 0.27; 'pass': 0.29; 'ignored.': 0.29; 'class': 0.29; 'topic': 0.30; 'seem': 0.30; 'construct': 0.30; 'ran': 0.30; 'skip:- 70': 0.31; "i've": 0.31; 'changes': 0.32; 'pretty': 0.32; 'header:X-Complaints-To:1': 0.33; 'to:addr:python-list': 0.34; 'test': 0.35; '...': 0.36; 'subject:with': 0.36; 'sequence': 0.37; 'but': 0.37; 'using': 0.38; 'replace': 0.38; 'received:org': 0.38; 'skip:o 20': 0.38; 'either': 0.39; 'should': 0.39; 'hit': 0.40; 'to:addr:python.org': 0.40; 'within': 0.60; 'more': 0.61; 'your': 0.61; 'order': 0.62; 'show': 0.67 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Peter Otten <__peter__@web.de> |
| Subject | Re: replacing __dict__ with an OrderedDict |
| Date | Fri, 06 Jan 2012 12:44:21 +0100 |
| Organization | None |
| References | <hjsit8-j0a.ln1@satorlaser.homedns.org> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset="ISO-8859-1" |
| Content-Transfer-Encoding | 7Bit |
| X-Gmane-NNTP-Posting-Host | p5084a0cb.dip.t-dialin.net |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.12 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.4477.1325850270.27778.python-list@python.org> (permalink) |
| Lines | 55 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1325850270 news.xs4all.nl 6932 [2001:888:2000:d::a6]:49897 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:18598 |
Show key headers only | View raw
Ulrich Eckhardt wrote:
> 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.
Alternatively you can write your own test loader:
$ cat ordered_unittest2.py
import unittest
class Test(unittest.TestCase):
def test_gamma(self):
pass
def test_beta(self):
pass
def test_alpha(self):
pass
class Loader(unittest.TestLoader):
def getTestCaseNames(self, testCaseClass):
"""Return a sequence of method names found within testCaseClass
sorted by co_firstlineno.
"""
def first_lineno(name):
method = getattr(testCaseClass, name)
return method.im_func.__code__.co_firstlineno
function_names = super(Loader, self).getTestCaseNames(testCaseClass)
function_names.sort(key=first_lineno)
return function_names
if __name__ == "__main__":
unittest.main(testLoader=Loader())
$ python2.7 ordered_unittest2.py -v
test_gamma (__main__.Test) ... ok
test_beta (__main__.Test) ... ok
test_alpha (__main__.Test) ... ok
----------------------------------------------------------------------
Ran 3 tests in 0.001s
OK
$
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
replacing __dict__ with an OrderedDict Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2012-01-06 10:48 +0100
Re: replacing __dict__ with an OrderedDict Lie Ryan <lie.1296@gmail.com> - 2012-01-06 22:43 +1100
Re: replacing __dict__ with an OrderedDict Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2012-01-06 14:36 +0100
Re: replacing __dict__ with an OrderedDict Lie Ryan <lie.1296@gmail.com> - 2012-01-07 04:01 +1100
Re: replacing __dict__ with an OrderedDict Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-01-07 00:45 +0000
Re: replacing __dict__ with an OrderedDict Ian Kelly <ian.g.kelly@gmail.com> - 2012-01-06 10:20 -0700
Re: replacing __dict__ with an OrderedDict Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-01-07 00:49 +0000
Re: replacing __dict__ with an OrderedDict Lie Ryan <lie.1296@gmail.com> - 2012-01-07 12:21 +1100
Re: replacing __dict__ with an OrderedDict Ian Kelly <ian.g.kelly@gmail.com> - 2012-01-06 18:24 -0700
Re: replacing __dict__ with an OrderedDict Eelco <hoogendoorn.eelco@gmail.com> - 2012-01-08 14:03 -0800
Re: replacing __dict__ with an OrderedDict Lie Ryan <lie.1296@gmail.com> - 2012-01-09 23:10 +1100
Re: replacing __dict__ with an OrderedDict Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2012-01-09 14:16 +0100
Re: replacing __dict__ with an OrderedDict Lie Ryan <lie.1296@gmail.com> - 2012-01-10 23:31 +1100
Re: replacing __dict__ with an OrderedDict Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2012-01-10 18:21 +0100
Re: replacing __dict__ with an OrderedDict Roy Smith <roy@panix.com> - 2012-01-09 09:35 -0500
Re: replacing __dict__ with an OrderedDict Neil Cerutti <neilc@norwich.edu> - 2012-01-09 14:52 +0000
Re: replacing __dict__ with an OrderedDict Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2012-01-09 17:59 +0100
Re: replacing __dict__ with an OrderedDict Ian Kelly <ian.g.kelly@gmail.com> - 2012-01-09 10:30 -0700
Re: replacing __dict__ with an OrderedDict Roy Smith <roy@panix.com> - 2012-01-09 20:05 -0500
Re: replacing __dict__ with an OrderedDict Terry Reedy <tjreedy@udel.edu> - 2012-01-09 23:21 -0500
Re: replacing __dict__ with an OrderedDict Lie Ryan <lie.1296@gmail.com> - 2012-01-10 23:22 +1100
Re: replacing __dict__ with an OrderedDict Roy Smith <roy@panix.com> - 2012-01-10 09:05 -0500
Re: replacing __dict__ with an OrderedDict Lie Ryan <lie.1296@gmail.com> - 2012-01-11 02:57 +1100
Re: replacing __dict__ with an OrderedDict Roy Smith <roy@panix.com> - 2012-01-10 21:47 -0500
Re: replacing __dict__ with an OrderedDict Tim Wintle <tim.wintle@teamrubber.com> - 2012-01-10 15:45 +0000
Re: replacing __dict__ with an OrderedDict Lie Ryan <lie.1296@gmail.com> - 2012-01-10 23:46 +1100
Re: replacing __dict__ with an OrderedDict Lie Ryan <lie.1296@gmail.com> - 2012-01-07 04:42 +1100
Re: replacing __dict__ with an OrderedDict Peter Otten <__peter__@web.de> - 2012-01-06 12:44 +0100
Re: replacing __dict__ with an OrderedDict Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2012-01-06 14:40 +0100
Re: replacing __dict__ with an OrderedDict Ian Kelly <ian.g.kelly@gmail.com> - 2012-01-06 09:06 -0700
Re: replacing __dict__ with an OrderedDict alex23 <wuwei23@gmail.com> - 2012-01-08 20:58 -0800
Re: replacing __dict__ with an OrderedDict Ian Kelly <ian.g.kelly@gmail.com> - 2012-01-06 09:07 -0700
Re: replacing __dict__ with an OrderedDict Arnaud Delobelle <arnodel@gmail.com> - 2012-01-06 21:38 +0000
Re: replacing __dict__ with an OrderedDict Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2012-01-18 11:29 +0100
Re: replacing __dict__ with an OrderedDict Ethan Furman <ethan@stoneleaf.us> - 2012-01-06 06:13 -0800
Re: replacing __dict__ with an OrderedDict Arnaud Delobelle <arnodel@gmail.com> - 2012-01-06 21:32 +0000
csiph-web