[OE-core] [PATCH v2 06/10] oe-selftest: fix handling of test cases without ID in --list-tests-by
Burton, Ross
ross.burton at intel.com
Thu Nov 10 20:05:12 UTC 2016
On 10 November 2016 at 12:18, Maciej Borzecki <maciej.borzecki at rndity.com>
wrote:
> - ts = sorted([ (tc.tcid, tc.tctag, tc.tcname, tc.tcclass, tc.tcmodule)
> for tc in get_testsuite_by(criteria, keyword) ])
> -
> - print('%-4s\t%-20s\t%-60s\t%-25s\t%-20s' % ('id', 'tag', 'name',
> 'class', 'module'))
> + def tc_key(t):
> + if t[0] is None:
> + return (0,) + t[1:]
> + return t
> + # tcid may be None if no ID was assigned, in which case sorted() will
> throw
> + # a TypeError as Python 3 does not allow comparison (<,<=,>=,>) of
> + # heterogeneous types, handle this by using a custom key generator
> + ts = sorted([ (tc.tcid, tc.tctag, tc.tcname, tc.tcclass, tc.tcmodule)
> \
> + for tc in get_testsuite_by(criteria, keyword) ],
> key=tc_key)
>
Wouldn't a shorter (but untested!) form alternative be just?
- ts = sorted([ (tc.tcid, tc.tctag, tc.tcname, tc.tcclass, tc.tcmodule)
for tc in get_testsuite_by(criteria, keyword) ])
+ ts = sorted([ (tc.tcid or 0, tc.tctag, tc.tcname, tc.tcclass,
tc.tcmodule) for tc in get_testsuite_by(criteria, keyword) ])
Ross
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openembedded.org/pipermail/openembedded-core/attachments/20161110/e2257168/attachment-0002.html>
More information about the Openembedded-core
mailing list