On Thursday 22 May 2014 11:52:09 Burton, Ross wrote: > On 21 May 2014 16:10, Lucian Musat <[email protected]> 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 -- _______________________________________________ Openembedded-core mailing list [email protected] http://lists.openembedded.org/mailman/listinfo/openembedded-core
