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

Burton, Ross ross.burton at intel.com
Thu May 22 10:52:09 UTC 2014


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.

Ross



More information about the Openembedded-core mailing list