[OE-core] [PATCH 1/2] Added test case numbers to test cases to aid in future automation of testopia status change.

Paul Eggleton paul.eggleton at linux.intel.com
Thu May 22 12:12:29 UTC 2014


On Thursday 22 May 2014 11:52:09 Burton, Ross wrote:
> On 21 May 2014 16:10, Lucian Musat <georgex.l.musat at intel.com> wrote:
> > -    def test_bitbakelayers_showcrossdepends(self):
> 
> > +    def test_bitbakelayers_showcrossdepends_tc_756(self):
> That's a bit ugly, and not very easy to extract.
> 
> Assuming that we control the logging, I'd suggest using a decorator to
> add the test case numbers to the function objects:
> 
> # This decorator takes an argument and sets it as the test_case member
> def testcase(number):
>     def decorator(func):
>         func.test_case = number
>         return func
>     return decorator
> 
> @testcase(42)
> def test_method():
>     print "Hello, world!"
> 
> print "Executing test (test case %d)" % test_method.test_case
> test_method()
> 
> Now you can extract the test case programatically, instead of relying
> on the method name containing the number.  The decorator can be
> extended to set more fields to other useful information too.

Good call, I wouldn't have thought of using a decorator in this way.

Cheers,
Paul

-- 

Paul Eggleton
Intel Open Source Technology Centre



More information about the Openembedded-core mailing list