On Thu, Nov 10, 2016 at 9:05 PM, Burton, Ross <ross.bur...@intel.com> wrote:
>
> On 10 November 2016 at 12:18, Maciej Borzecki <maciej.borze...@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) ])
>

Well, yes, that would work too. A downside though, is that the output of
--list-tests and --list-tests would be different. For --list-test, TCs without
ID would have None in the first column, while the same TCs in --lists-tests-by
would end up having 0.

I've tried to keep the output of both tools consistent. Also, 'None' seems to be
more a better fit in this case, as there's no ID.

Cheers,
-- 
Maciej Borzecki
RnDity
-- 
_______________________________________________
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core

Reply via email to