Ejemplo n.º 1
0
    def _template_to_factory(test_parameters, template, variant):
        """
        Applies test params from variant to the test template

        :param test_parameters: a simpler set of parameters (currently
                                given to the run command via "-p" parameters)
        :param template: a test template, containing the class name,
                         followed by parameters to the class
        :type template: tuple
        :param variant: variant to be applied, usually containing
                        the keys: paths, variant and variant_id
        :type variant: dict
        :return: tuple(new_test_factory, applied_variant)
        """
        var = variant.get("variant")
        paths = variant.get("paths")

        original_params_to_klass = template[1]
        if "params" not in original_params_to_klass:
            params_to_klass = original_params_to_klass.copy()
            if test_parameters:
                var[0] = tree.TreeNode().get_node("/", True)
                var[0].value = test_parameters
                paths = ["/"]
            params_to_klass["params"] = (var, paths)
            factory = [template[0], params_to_klass]
            return factory, variant

        return template, {"variant": var,
                          "variant_id": varianter.generate_variant_id(var),
                          "paths": paths}
Ejemplo n.º 2
0
    def initialize_mux(self, root, paths):
        """
        Initialize the basic values

        :note: We can't use __init__ as this object is intended to be used
               via dispatcher with no __init__ arguments.
        """
        self.root = root
        self.paths = paths
        self.variant_ids = [varianter.generate_variant_id(variant)
                            for variant in MuxTree(self.root)]
Ejemplo n.º 3
0
    def initialize_mux(self, root, paths, debug):
        """
        Initialize the basic values

        :note: We can't use __init__ as this object is intended to be used
               via dispatcher with no __init__ arguments.
        """
        self.root = root
        self.paths = paths
        self.debug = debug
        self.variant_ids = [varianter.generate_variant_id(variant)
                            for variant in MuxTree(self.root)]
Ejemplo n.º 4
0
    def _template_to_factory(test_parameters, template, variant):
        """
        Applies test params from variant to the test template

        :param test_parameters: a simpler set of parameters (currently
                                given to the run command via "-p" parameters)
        :param template: a test template, containing the class name,
                         followed by parameters to the class
        :type template: tuple
        :param variant: variant to be applied, usually containing
                        the keys: paths, variant and variant_id
        :type variant: dict
        :return: tuple(new_test_factory, applied_variant)
        """
        var = variant.get("variant")
        paths = variant.get("paths")
        empty_variants = varianter.is_empty_variant(var)

        original_params_to_klass = template[1]
        if "params" not in original_params_to_klass:
            params_to_klass = original_params_to_klass.copy()
            if test_parameters and empty_variants:
                var[0] = tree.TreeNode().get_node("/", True)
                var[0].value = test_parameters
                paths = ["/"]
            params_to_klass["params"] = (var, paths)
            factory = [template[0], params_to_klass]
            return factory, variant

        if not empty_variants:
            raise NotImplementedError(
                "Specifying test params from test loader "
                "and from varianter at the same time is "
                "not yet supported. Please remove either "
                "variants defined by the varianter (%s) "
                "or make the test loader of test %s to "
                "not to fill variants." % (variant, template))

        return template, {
            "variant": var,
            "variant_id": varianter.generate_variant_id(var),
            "paths": paths
        }
Ejemplo n.º 5
0
Archivo: mux.py Proyecto: ptabc/avocado
 def _get_variant_ids(self):
     return [
         varianter.generate_variant_id(variant)
         for variant in MuxTree(self.root)
     ]
Ejemplo n.º 6
0
 def _get_variant_ids(self):
     return [varianter.generate_variant_id(variant)
             for variant in MuxTree(self.root)]