未验证 提交 8c1584af 编写于 作者: A Amador Pahim

Merge branch 'clebergnu-parameters_varianter_and_runner_v2'

Signed-off-by: NAmador Pahim <apahim@redhat.com>
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# See LICENSE for more details.
#
# Copyright: Red Hat Inc. 2014-2017
"""
Module related to test parameters
"""
import re
from six import iterkeys, iteritems
from six.moves import xrange as range
from . import output
class NoMatchError(KeyError):
pass
class AvocadoParams(object):
"""
Params object used to retrieve params from given path. It supports
absolute and relative paths. For relative paths one can define multiple
paths to search for the value.
It contains compatibility wrapper to act as the original avocado Params,
but by special usage you can utilize the new API. See ``get()``
docstring for details.
You can also iterate through all keys, but this can generate quite a lot
of duplicate entries inherited from ancestor nodes. It shouldn't produce
false values, though.
In this version each new "get()" call is logged into avocado.LOG_JOB.
This is subject of change (separate file, perhaps)
"""
# TODO: Use "test" to log params.get()
def __init__(self, leaves, test_id, mux_path):
"""
:param leaves: List of TreeNode leaves defining current variant
:param test_id: test id
:param mux_path: list of entry points
"""
self._rel_paths = []
leaves = list(leaves)
for i, path in enumerate(mux_path):
path_leaves = self._get_matching_leaves(path, leaves)
self._rel_paths.append(AvocadoParam(path_leaves,
'%d: %s' % (i, path)))
# Don't use non-mux-path params for relative paths
path_leaves = self._get_matching_leaves('/*', leaves)
self._abs_path = AvocadoParam(path_leaves, '*: *')
self.id = test_id
self._cache = {} # TODO: Implement something more efficient
def __eq__(self, other):
if set(iterkeys(self.__dict__)) != set(iterkeys(other.__dict__)):
return False
for attr in iterkeys(self.__dict__):
if (getattr(self, attr) != getattr(other, attr)):
return False
return True
def __ne__(self, other):
return not (self == other)
def __getstate__(self):
""" log can't be pickled """
copy = self.__dict__.copy()
return copy
def __setstate__(self, orig):
""" refresh log """
self.__dict__.update(orig)
def __repr__(self):
return "<AvocadoParams %s>" % self._str()
def __str__(self):
return "params {%s}" % self._str()
def _str(self):
out = ",".join(_.str_leaves_variant for _ in self._rel_paths)
if out:
return self._abs_path.str_leaves_variant + ',' + out
else:
return self._abs_path.str_leaves_variant
def log(self, key, path, default, value):
""" Predefined format for displaying params query """
output.LOG_JOB.debug("PARAMS (key=%s, path=%s, default=%s) => %r", key,
path, default, value)
def _get_matching_leaves(self, path, leaves):
"""
Pops and returns list of matching nodes
:param path: Path (str)
:param leaves: list of TreeNode leaves
"""
path = self._greedy_path(path)
path_leaves = [leaf for leaf in leaves if path.search(leaf.path + '/')]
for leaf in path_leaves:
leaves.remove(leaf)
return path_leaves
@staticmethod
def _greedy_path(path):
"""
converts user-friendly asterisk path to python regexp and compiles it:
path = "" => ^$
path = "/" => /
path = "/foo/bar" => /foo/bar
path = "foo/bar" => $MUX_ENTRY/?.*/foo/bar
path = "/*/foo" => /[^/]*/foo
path = "foo/*" => $MUX_ENTRY/?.*/foo/.*
path = "/foo/*" => /foo/.*
"""
if not path:
return re.compile('^$')
if path[-1] == '*':
suffix = ''
path = path[:-1]
else:
suffix = '$'
return re.compile(path.replace('*', '[^/]*') + suffix)
@staticmethod
def _is_abspath(path):
""" Is this an absolute or relative path? """
if path.pattern and path.pattern[0] == '/':
return True
else:
return False
def get(self, key, path=None, default=None):
"""
Retrieve value associated with key from params
:param key: Key you're looking for
:param path: namespace ['*']
:param default: default value when not found
:raise KeyError: In case of multiple different values (params clash)
"""
if path is None: # default path is any relative path
path = '*'
try:
return self._cache[(key, path, default)]
except (KeyError, TypeError):
# KeyError - first query
# TypeError - unable to hash
value = self._get(key, path, default)
self.log(key, path, default, value)
try:
self._cache[(key, path, default)] = value
except TypeError:
pass
return value
def _get(self, key, path, default):
"""
Actual params retrieval
:param key: key you're looking for
:param path: namespace
:param default: default value when not found
:raise KeyError: In case of multiple different values (params clash)
"""
path = self._greedy_path(path)
for param in self._rel_paths:
try:
return param.get_or_die(path, key)
except NoMatchError:
pass
if self._is_abspath(path):
try:
return self._abs_path.get_or_die(path, key)
except NoMatchError:
pass
return default
def objects(self, key, path=None):
"""
Return the names of objects defined using a given key.
:param key: The name of the key whose value lists the objects
(e.g. 'nics').
"""
return self.get(path, key, "").split()
def iteritems(self):
"""
Iterate through all available params and yield origin, key and value
of each unique value.
"""
env = []
for param in self._rel_paths:
for path, key, value in param.iteritems():
if (path, key) not in env:
env.append((path, key))
yield (path, key, value)
for path, key, value in self._abs_path.iteritems():
if (path, key) not in env:
env.append((path, key))
yield (path, key, value)
class AvocadoParam(object):
"""
This is a single slice params. It can contain multiple leaves and tries to
find matching results.
"""
def __init__(self, leaves, name):
"""
:param leaves: this slice's leaves
:param name: this slice's name (identifier used in exceptions)
"""
# Basic initialization
self._leaves = leaves
# names cache (leaf.path is quite expensive)
self._leaf_names = [leaf.path + '/' for leaf in leaves]
self.name = name
def __eq__(self, other):
if self.__dict__ == other.__dict__:
return True
else:
return False
def __ne__(self, other):
return not (self == other)
@property
def str_leaves_variant(self):
""" String with identifier and all params """
return "%s (%s)" % (self.name, self._leaf_names)
def _get_leaves(self, path):
"""
Get all leaves matching the path
"""
return [self._leaves[i]
for i in range(len(self._leaf_names))
if path.search(self._leaf_names[i])]
def get_or_die(self, path, key):
"""
Get a value or raise exception if not present
:raise NoMatchError: When no matches
:raise KeyError: When value is not certain (multiple matches)
"""
leaves = self._get_leaves(path)
ret = [(leaf.environment[key], leaf.environment.origin[key])
for leaf in leaves
if key in leaf.environment]
if not ret:
raise NoMatchError("No matches to %s => %s in %s"
% (path.pattern, key, self.str_leaves_variant))
if len(set([_[1] for _ in ret])) == 1: # single source of results
return ret[0][0]
else:
raise ValueError("Multiple %s leaves contain the key '%s'; %s"
% (path.pattern, key,
["%s=>%s" % (_[1].path, _[0])
for _ in ret]))
def iteritems(self):
"""
Very basic implementation which iterates through __ALL__ params,
which generates lots of duplicate entries due to inherited values.
"""
for leaf in self._leaves:
for key, value in iteritems(leaf.environment):
yield (leaf.environment.origin[key].path, key, value)
......@@ -274,6 +274,10 @@ class TestRunner(object):
"""
DEFAULT_TIMEOUT = 86400
#: Mode in which this runner should iterate through tests and variants.
#: The allowed values are "variants-per-test" or "tests-per-variant"
DEFAULT_EXECUTION_ORDER = "variants-per-test"
def __init__(self, job, result):
"""
Creates an instance of TestRunner class.
......@@ -506,31 +510,35 @@ class TestRunner(object):
"""
Applies test params from variant to the test template
:param template: a test template
:param variant: variant to be applied
: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: mux_path, variant and variant_id
:type variant: dict
:return: tuple(new_test_factory, applied_variant)
"""
params = variant.get("variant"), variant.get("mux_path")
if params:
if "params" in template[1]:
if not varianter.is_empty_variant(params[0]):
msg = ("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))
raise NotImplementedError(msg)
params = template[1]["params"]
variant_id = varianter.generate_variant_id(params[0])
return template, {"variant": params[0],
"variant_id": variant_id,
"mux_path": params[1]}
factory = [template[0], template[1].copy()]
factory[1]["params"] = params
var = variant.get("variant")
mux_path = variant.get("mux_path")
klass, klass_parameters = template
if "params" in klass_parameters:
if not varianter.is_empty_variant(var):
msg = ("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))
raise NotImplementedError(msg)
params = klass_parameters["params"]
variant_id = varianter.generate_variant_id(var)
return template, {"variant": var,
"variant_id": variant_id,
"mux_path": mux_path}
else:
factory = template
return factory, variant
factory = [klass, klass_parameters.copy()]
factory[1]["params"] = (var, mux_path)
return factory, variant
def _iter_suite(self, test_suite, variants, execution_order):
"""
......@@ -541,7 +549,7 @@ class TestRunner(object):
:param execution_order: way of iterating through tests/variants
:return: generator yielding tuple(test_factory, variant)
"""
if execution_order in ("variants-per-test", None):
if execution_order == "variants-per-test":
return (self._template_to_factory(template, variant)
for template in test_suite
for variant in variants.itertests())
......@@ -564,7 +572,8 @@ class TestRunner(object):
:param replay_map: optional list to override test class based on test
index.
:param execution_order: Mode in which we should iterate through tests
resp. variants.
and variants. If not provided, will default to
:attr:`DEFAULT_EXECUTION_ORDER`.
:return: a set with types of test failures.
"""
summary = set()
......@@ -591,6 +600,8 @@ class TestRunner(object):
for test_template in test_suite:
test_template[1]["base_logdir"] = self.job.logdir
test_template[1]["job"] = self.job
if execution_order is None:
execution_order = self.DEFAULT_EXECUTION_ORDER
for test_factory, variant in self._iter_suite(test_suite, variants,
execution_order):
index += 1
......
......@@ -33,9 +33,9 @@ from six import string_types, iteritems
from . import data_dir
from . import exceptions
from . import varianter
from . import sysinfo
from . import output
from . import parameters
from . import sysinfo
from ..utils import asset
from ..utils import astring
from ..utils import data_structures
......@@ -286,8 +286,6 @@ class Test(unittest.TestCase, TestData):
You'll inherit from this to write your own tests. Typically you'll want
to implement setUp(), test*() and tearDown() methods on your own tests.
"""
#: `default_params` will be deprecated by the end of 2017.
default_params = {}
#: Arbitrary string which will be stored in `$logdir/whiteboard` location
#: when the test finishes.
whiteboard = ''
......@@ -364,17 +362,12 @@ class Test(unittest.TestCase, TestData):
self.log.warn = self.log.warning = record_and_warn
mux_path = ['/test/*']
if isinstance(params, dict):
self.default_params = self.default_params.copy()
self.default_params.update(params)
params = []
elif params is None:
if params is None:
params = []
elif isinstance(params, tuple):
params, mux_path = params[0], params[1]
self.__params = varianter.AvocadoParams(params, self.name,
mux_path,
self.default_params)
self.__params = parameters.AvocadoParams(params, self.name,
mux_path)
default_timeout = getattr(self, "timeout", None)
self.timeout = self.params.get("timeout", default=default_timeout)
......
......@@ -16,303 +16,18 @@
# Lucas Meneghel Rodrigues <lmr@redhat.com>
"""
Multiplex and create variants.
Base classes for implementing the varianter interface
"""
import hashlib
import re
from six import iterkeys, iteritems, itervalues
from six.moves import xrange as range
from six import iteritems, itervalues
from . import tree
from . import dispatcher
from . import output
class NoMatchError(KeyError):
pass
class AvocadoParams(object):
"""
Params object used to retrieve params from given path. It supports
absolute and relative paths. For relative paths one can define multiple
paths to search for the value.
It contains compatibility wrapper to act as the original avocado Params,
but by special usage you can utilize the new API. See ``get()``
docstring for details.
You can also iterate through all keys, but this can generate quite a lot
of duplicate entries inherited from ancestor nodes. It shouldn't produce
false values, though.
In this version each new "get()" call is logged into avocado.LOG_JOB.
This is subject of change (separate file, perhaps)
"""
# TODO: Use "test" to log params.get()
def __init__(self, leaves, test_id, mux_path, default_params):
"""
:param leaves: List of TreeNode leaves defining current variant
:param test_id: test id
:param mux_path: list of entry points
:param default_params: dict of params used when no matches found
.. note:: `default_params` will be deprecated by the end of 2017.
"""
self._rel_paths = []
leaves = list(leaves)
for i, path in enumerate(mux_path):
path_leaves = self._get_matching_leaves(path, leaves)
self._rel_paths.append(AvocadoParam(path_leaves,
'%d: %s' % (i, path)))
# Don't use non-mux-path params for relative paths
path_leaves = self._get_matching_leaves('/*', leaves)
self._abs_path = AvocadoParam(path_leaves, '*: *')
self.id = test_id
self._cache = {} # TODO: Implement something more efficient
# TODO: Get rid of this and prepare something better
self._default_params = default_params
def __eq__(self, other):
if set(iterkeys(self.__dict__)) != set(iterkeys(other.__dict__)):
return False
for attr in iterkeys(self.__dict__):
if (getattr(self, attr) != getattr(other, attr)):
return False
return True
def __ne__(self, other):
return not (self == other)
def __getstate__(self):
""" log can't be pickled """
copy = self.__dict__.copy()
return copy
def __setstate__(self, orig):
""" refresh log """
self.__dict__.update(orig)
def __repr__(self):
return "<AvocadoParams %s>" % self._str()
def __str__(self):
return "params {%s}" % self._str()
def _str(self):
out = ",".join(_.str_leaves_variant for _ in self._rel_paths)
if out:
return self._abs_path.str_leaves_variant + ',' + out
else:
return self._abs_path.str_leaves_variant
def log(self, key, path, default, value):
""" Predefined format for displaying params query """
output.LOG_JOB.debug("PARAMS (key=%s, path=%s, default=%s) => %r", key,
path, default, value)
def _get_matching_leaves(self, path, leaves):
"""
Pops and returns list of matching nodes
:param path: Path (str)
:param leaves: list of TreeNode leaves
"""
path = self._greedy_path(path)
path_leaves = [leaf for leaf in leaves if path.search(leaf.path + '/')]
for leaf in path_leaves:
leaves.remove(leaf)
return path_leaves
@staticmethod
def _greedy_path(path):
"""
converts user-friendly asterisk path to python regexp and compiles it:
path = "" => ^$
path = "/" => /
path = "/foo/bar" => /foo/bar
path = "foo/bar" => $MUX_ENTRY/?.*/foo/bar
path = "/*/foo" => /[^/]*/foo
path = "foo/*" => $MUX_ENTRY/?.*/foo/.*
path = "/foo/*" => /foo/.*
"""
if not path:
return re.compile('^$')
if path[-1] == '*':
suffix = ''
path = path[:-1]
else:
suffix = '$'
return re.compile(path.replace('*', '[^/]*') + suffix)
@staticmethod
def _is_abspath(path):
""" Is this an absolute or relative path? """
if path.pattern and path.pattern[0] == '/':
return True
else:
return False
def __getattr__(self, attr):
"""
Compatibility to old Params
:warning: This will be removed soon. Use params.get() instead
"""
if attr == '__getnewargs__': # pickling uses this attr
raise AttributeError
elif attr in self.__dict__:
return self.__dict__[attr]
else:
msg = ("You're probably retrieving param %s via attributes "
" (self.params.$key) which is obsoleted. Use "
"self.params.get($key) instead." % attr)
output.LOG_JOB.warn(msg)
return self.get(attr)
def get(self, key, path=None, default=None):
"""
Retrieve value associated with key from params
:param key: Key you're looking for
:param path: namespace ['*']
:param default: default value when not found
:raise KeyError: In case of multiple different values (params clash)
"""
if path is None: # default path is any relative path
path = '*'
try:
return self._cache[(key, path, default)]
except (KeyError, TypeError):
# KeyError - first query
# TypeError - unable to hash
value = self._get(key, path, default)
self.log(key, path, default, value)
try:
self._cache[(key, path, default)] = value
except TypeError:
pass
return value
def _get(self, key, path, default):
"""
Actual params retrieval
:param key: key you're looking for
:param path: namespace
:param default: default value when not found
:raise KeyError: In case of multiple different values (params clash)
"""
path = self._greedy_path(path)
for param in self._rel_paths:
try:
return param.get_or_die(path, key)
except NoMatchError:
pass
if self._is_abspath(path):
try:
return self._abs_path.get_or_die(path, key)
except NoMatchError:
pass
return self._default_params.get(key, default)
def objects(self, key, path=None):
"""
Return the names of objects defined using a given key.
:param key: The name of the key whose value lists the objects
(e.g. 'nics').
"""
return self.get(path, key, "").split()
def iteritems(self):
"""
Iterate through all available params and yield origin, key and value
of each unique value.
"""
env = []
for param in self._rel_paths:
for path, key, value in param.iteritems():
if (path, key) not in env:
env.append((path, key))
yield (path, key, value)
for path, key, value in self._abs_path.iteritems():
if (path, key) not in env:
env.append((path, key))
yield (path, key, value)
class AvocadoParam(object):
"""
This is a single slice params. It can contain multiple leaves and tries to
find matching results.
"""
def __init__(self, leaves, name):
"""
:param leaves: this slice's leaves
:param name: this slice's name (identifier used in exceptions)
"""
# Basic initialization
self._leaves = leaves
# names cache (leaf.path is quite expensive)
self._leaf_names = [leaf.path + '/' for leaf in leaves]
self.name = name
def __eq__(self, other):
if self.__dict__ == other.__dict__:
return True
else:
return False
def __ne__(self, other):
return not (self == other)
@property
def str_leaves_variant(self):
""" String with identifier and all params """
return "%s (%s)" % (self.name, self._leaf_names)
def _get_leaves(self, path):
"""
Get all leaves matching the path
"""
return [self._leaves[i]
for i in range(len(self._leaf_names))
if path.search(self._leaf_names[i])]
def get_or_die(self, path, key):
"""
Get a value or raise exception if not present
:raise NoMatchError: When no matches
:raise KeyError: When value is not certain (multiple matches)
"""
leaves = self._get_leaves(path)
ret = [(leaf.environment[key], leaf.environment.origin[key])
for leaf in leaves
if key in leaf.environment]
if not ret:
raise NoMatchError("No matches to %s => %s in %s"
% (path.pattern, key, self.str_leaves_variant))
if len(set([_[1] for _ in ret])) == 1: # single source of results
return ret[0][0]
else:
raise ValueError("Multiple %s leaves contain the key '%s'; %s"
% (path.pattern, key,
["%s=>%s" % (_[1].path, _[0])
for _ in ret]))
def iteritems(self):
"""
Very basic implementation which iterates through __ALL__ params,
which generates lots of duplicate entries due to inherited values.
"""
for leaf in self._leaves:
for key, value in iteritems(leaf.environment):
yield (leaf.environment.origin[key].path, key, value)
def is_empty_variant(variant):
"""
Reports whether the variant contains any data
......
......@@ -70,18 +70,6 @@ Overall picture of how the params handling works is:
Let's introduce the basic keywords.
Test's default params
~~~~~~~~~~~~~~~~~~~~~
:data:`avocado.core.test.Test.default_params`
Every (instrumented) test can hardcode default params by storing a dict
in ``self.default_params``. This attribute is checked during
:class:`avocado.core.test.Test`'s ``__init__`` phase and if present it's
used by `AvocadoParams`_.
.. warning:: Don't confuse `Test's default params`_ with `Default params`
TreeNode
~~~~~~~~
......@@ -99,11 +87,11 @@ AvocadoParams
:class:`avocado.core.varianter.AvocadoParams`
Is a "database" of params present in every (instrumented) avocado test.
It's produced during :class:`avocado.core.test.Test`'s ``__init__``
from a `variant`_. It accepts a list of `TreeNode`_ objects; test name
:class:`avocado.core.test.TestID` (for logging purposes); list of
default paths (`Mux path`_) and the `Test's default params`_.
Is a "database" of params present in every (instrumented) avocado
test. It's produced during :class:`avocado.core.test.Test`'s
``__init__`` from a `variant`_. It accepts a list of `TreeNode`_
objects; test name :class:`avocado.core.test.TestID` (for logging
purposes) and a list of default paths (`Mux path`_).
In test it allows querying for data by using::
......@@ -143,13 +131,11 @@ More practical overview of mux path is in :ref:`yaml-to-mux-plugin` in
Variant
~~~~~~~
Variant is a set of params produced by `Varianter`_s and passed to
the test by the test runner as ``params`` argument. The simplest variant
is ``None``, which still produces `AvocadoParams`_ with only the
`Test's default params`_. If dict is used as a `Variant`_, it (safely)
updates the default params. Last but not least the `Variant`_ can also
be a ``tuple(list, mux_path)`` or just the ``list`` of
:class:`avocado.core.tree.TreeNode` with the params.
Variant is a set of params produced by `Varianter`_s and passed to the
test by the test runner as ``params`` argument. The simplest variant
is ``None``, which still produces an empty `AvocadoParams`_. Also, the
`Variant`_ can also be a ``tuple(list, mux_path)`` or just the
``list`` of :class:`avocado.core.tree.TreeNode` with the params.
Varianter
~~~~~~~~~
......@@ -216,14 +202,14 @@ of them reports variants it yields them instead of the default variant.
Default params
~~~~~~~~~~~~~~
Unlike `Test's default params`_ the `Default params`_ is a mechanism to
specify default values in `Varianter`_ or `Varianter plugins`_. Their
purpose is usually to define values dependent on the system which should
not affect the test's results. One example is a qemu binary location
which might differ from one host to another host, but in the end
they should result in qemu being executable in test. For this reason
the `Default params`_ do not affects the test's variant-id (at least
not in the official `Varianter plugins`_).
The `Default params`_ is a mechanism to specify default values in
`Varianter`_ or `Varianter plugins`_. Their purpose is usually to
define values dependent on the system which should not affect the
test's results. One example is a qemu binary location which might
differ from one host to another host, but in the end they should
result in qemu being executable in test. For this reason the `Default
params`_ do not affects the test's variant-id (at least not in the
official `Varianter plugins`_).
These params can be set from plugin/core by getting ``default_avocado_params``
from ``args`` and using::
......
......@@ -14,7 +14,7 @@ class TimeoutTest(Test):
:param sleep_time: How long should the test sleep
"""
default_params = {'timeout': 3}
timeout = 3
def test(self):
"""
......
......@@ -18,7 +18,7 @@ import copy
from six import iteritems
from avocado.core import loader
from avocado.core import varianter
from avocado.core import parameters
from avocado.core.plugin_interfaces import CLI
from avocado_varianter_yaml_to_mux import create_from_yaml
from avocado_varianter_yaml_to_mux import mux
......@@ -100,8 +100,8 @@ class YamlTestsuiteLoader(loader.TestLoader):
return []
mux_tree = mux.MuxTree(root)
for variant in mux_tree:
params = varianter.AvocadoParams(variant, "YamlTestsuiteLoader",
["/run/*"], {})
params = parameters.AvocadoParams(variant, "YamlTestsuiteLoader",
["/run/*"])
reference = params.get("test_reference")
test_loader = self._get_loader(params)
if not test_loader:
......
......@@ -22,7 +22,6 @@ from avocado.core.output import LOG_UI
from avocado.core.plugin_interfaces import CLI
from avocado.core.plugin_interfaces import Varianter
from avocado.core.tree import TreeNode
from avocado.core.varianter import AvocadoParams
from avocado.utils import path as utils_path
from avocado.utils import process
......
......@@ -22,7 +22,7 @@ import sys
from six import iteritems
from avocado.core import tree, exit_codes, varianter
from avocado.core import tree, exit_codes
from avocado.core.output import LOG_UI
from avocado.core.plugin_interfaces import CLI, Varianter
......
......@@ -9,7 +9,7 @@ from six import iteritems
import avocado_varianter_yaml_to_mux as yaml_to_mux
from avocado_varianter_yaml_to_mux import mux
from avocado.core import tree, varianter
from avocado.core import tree, parameters
BASEDIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', '..')
BASEDIR = os.path.abspath(BASEDIR)
......@@ -293,12 +293,12 @@ class TestAvocadoParams(unittest.TestCase):
yamls = yaml_to_mux.create_from_yaml(["/:" + PATH_PREFIX +
'selftests/.data/mux-selftest-params.yaml'])
self.yamls = iter(mux.MuxTree(yamls))
self.params1 = varianter.AvocadoParams(next(self.yamls), 'Unittest1',
['/ch0/*', '/ch1/*'], {})
self.params1 = parameters.AvocadoParams(next(self.yamls), 'Unittest1',
['/ch0/*', '/ch1/*'])
next(self.yamls) # Skip 2nd
next(self.yamls) # and 3rd
self.params2 = varianter.AvocadoParams(next(self.yamls), 'Unittest2',
['/ch1/*', '/ch0/*'], {})
self.params2 = parameters.AvocadoParams(next(self.yamls), 'Unittest2',
['/ch1/*', '/ch0/*'])
@unittest.skipIf(not yaml_to_mux.MULTIPLEX_CAPABLE, "Not multiplex capable")
def test_pickle(self):
......@@ -312,7 +312,7 @@ class TestAvocadoParams(unittest.TestCase):
self.assertNotEqual(self.params1, self.params2)
repr(self.params1)
str(self.params1)
str(varianter.AvocadoParams([], 'Unittest', [], {}))
str(parameters.AvocadoParams([], 'Unittest', []))
self.assertEqual(15, sum([1 for _ in iteritems(self.params1)]))
@unittest.skipIf(not yaml_to_mux.MULTIPLEX_CAPABLE, "Not multiplex capable")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册