예제 #1
0
파일: basetest.py 프로젝트: xiaorz/pmdk
    def __init__(cls, name, bases, dct):
        type.__init__(cls, name, bases, dct)

        # only classes deriving from BaseTest are meant to be used
        if cls.__base__.__name__ != 'BaseTest':
            return

        # globally register class as test case
        builtins.testcases.append(cls)

        # expand values of context classes attributes
        for attr, _ in CTX_COMPONENTS:
            if hasattr(cls, attr):
                val = getattr(cls, attr)
                if isinstance(val, list):
                    val = ctx.expand(*val)
                setattr(cls, attr, val)

        cls.name = cls.__name__
        try:
            cls.testnum = int(cls.__name__.replace('TEST', ''))
        except ValueError as e:
            print('Invalid test class name {}, should be "TEST[number]"'
                  .format(cls.__name__))
            raise e
예제 #2
0
파일: basetest.py 프로젝트: wlemkows/nvml
    def __init__(cls, name, bases, dct):
        type.__init__(cls, name, bases, dct)

        # only classes deriving from BaseTest are meant to be used
        if cls.__base__.__name__ != 'BaseTest':
            return

        # globally register class as test case
        builtins.testcases.append(cls)

        # expand values of context classes attributes
        for attr, _ in CTX_COMPONENTS:
            if hasattr(cls, attr):
                val = getattr(cls, attr)
                if isinstance(val, list):
                    val = ctx.expand(*val)
                setattr(cls, attr, val)

        cls.name = cls.__name__
        try:
            cls.testnum = int(cls.__name__.replace('TEST', ''))
        except ValueError as e:
            print('Invalid test class name {}, should be "TEST[number]"'
                  .format(cls.__name__))
            raise e
예제 #3
0
파일: basetest.py 프로젝트: virgilshi/pmdk
    def __init__(cls, name, bases, dct):
        type.__init__(cls, name, bases, dct)

        # globally register class as test case
        # only classes whose names start with 'TEST' are meant to be run
        if cls.__name__.startswith('TEST'):
            builtins.testcases.append(cls)

        # expand values of context classes attributes
        for attr, _ in CTX_COMPONENTS:
            if hasattr(cls, attr):
                val = getattr(cls, attr)
                if isinstance(val, list):
                    val = ctx.expand(*val)
                setattr(cls, attr, val)

        cls.name = cls.__name__
        cls._testnum = cls.__name__.replace('TEST', '')
예제 #4
0
파일: basetest.py 프로젝트: adrianjhpc/pmdk
    def _ctx_attrs_init(self):
        """
        Initialize test class attributes referring to selected context
        parameters (like build, fs). If attribute was not set by subclassing
        test, its value is set to respective config value. If it was set,
        it is filtered through config values.
        """

        for attr, base in CTX_COMPONENTS:
            conf_val = getattr(self.config, attr)
            if hasattr(self, attr):
                test_val = getattr(self, attr)
                if test_val == Any:
                    ctx_val = Any.get(conf_val)
                else:
                    ctx_val = futils.filter_contexts(conf_val, test_val)
            else:
                ctx_val = futils.filter_contexts(conf_val, None)
            setattr(self, attr, ctx.expand(*ctx_val))

        self._valgrind_init()
예제 #5
0
파일: basetest.py 프로젝트: adrianjhpc/pmdk
    def __init__(cls, name, bases, dct):
        type.__init__(cls, name, bases, dct)

        # globally register class as test case
        # only classes whose names start with 'TEST' are meant to be run
        if cls.__name__.startswith('TEST'):
            builtins.testcases.append(cls)
            try:
                cls.testnum = int(cls.__name__.replace('TEST', ''))
            except ValueError as e:
                print('Invalid test class name {}, should be "TEST[number]"'.
                      format(cls.name))
                raise e

        # expand values of context classes attributes
        for attr, _ in CTX_COMPONENTS:
            if hasattr(cls, attr):
                val = getattr(cls, attr)
                if isinstance(val, list):
                    val = ctx.expand(*val)
                setattr(cls, attr, val)

        cls.name = cls.__name__
 def convert_internal(key, base):
     if not isinstance(config[key], list):
         config[key] = ctx.expand(class_from_string(config[key], base))
     else:
         classes = [class_from_string(cl, base) for cl in config[key]]
         config[key] = ctx.expand(*classes)