summaryrefslogtreecommitdiff
path: root/framework
diff options
context:
space:
mode:
Diffstat (limited to 'framework')
-rw-r--r--framework/profile.py14
-rw-r--r--framework/tests/profile_tests.py30
2 files changed, 42 insertions, 2 deletions
diff --git a/framework/profile.py b/framework/profile.py
index 6d40d0ae7..e8e8ba18f 100644
--- a/framework/profile.py
+++ b/framework/profile.py
@@ -34,6 +34,7 @@ import multiprocessing.dummy
import importlib
import types
import contextlib
+import itertools
from framework.dmesg import get_dmesg
from framework.log import LogManager
@@ -271,7 +272,7 @@ class TestProfile(object):
self.test_list.update(profile.test_list)
@contextlib.contextmanager
- def group_manager(self, test_class, group):
+ def group_manager(self, test_class, group, prefix=None, **default_args):
"""A context manager to make working with flat groups simple.
This provides a simple way to replace add_plain_test,
@@ -291,6 +292,12 @@ class TestProfile(object):
group -- a string or unicode that will be used as the key for the test
in profile.
+ Keyword Arguments:
+ **default_args -- any additional keyword arguments will be considered
+ default arguments to all tests added by the adder.
+ They will always be overwritten by **kwargs passed to
+ the adder function
+
>>> from framework.test import PiglitGLTest
>>> p = TestProfile()
>>> with p.group_manager(PiglitGLTest, 'a') as g:
@@ -321,7 +328,10 @@ class TestProfile(object):
assert isinstance(name, basestring)
lgroup = grouptools.join(group, name)
- self.test_list[lgroup] = test_class(args, **kwargs)
+ self.test_list[lgroup] = test_class(
+ args,
+ **{k:v for k, v in itertools.chain(default_args.iteritems(),
+ kwargs.iteritems())})
yield adder
diff --git a/framework/tests/profile_tests.py b/framework/tests/profile_tests.py
index 0103de406..d2878c3c4 100644
--- a/framework/tests/profile_tests.py
+++ b/framework/tests/profile_tests.py
@@ -211,3 +211,33 @@ def test_testprofile_group_manager_is_added():
g(['a', 'b'], 'a')
nt.assert_in(grouptools.join('foo', 'a'), prof.test_list)
+
+
+def test_testprofile_groupmanager_kwargs():
+ """TestProfile.group_manager: Extra kwargs are passed to the Test."""
+ prof = profile.TestProfile()
+ with prof.group_manager(utils.Test, 'foo') as g:
+ g(['a'], run_concurrent=True)
+
+ test = prof.test_list[grouptools.join('foo', 'a')]
+ nt.assert_equal(test.run_concurrent, True)
+
+
+def test_testprofile_groupmanager_default_args():
+ """TestProfile.group_manager: group_manater kwargs are passed to the Test."""
+ prof = profile.TestProfile()
+ with prof.group_manager(utils.Test, 'foo', run_concurrent=True) as g:
+ g(['a'])
+
+ test = prof.test_list[grouptools.join('foo', 'a')]
+ nt.assert_equal(test.run_concurrent, True)
+
+
+def test_testprofile_groupmanager_kwargs_overwrite():
+ """TestProfile.group_manager: default_args are overwritten by kwargs."""
+ prof = profile.TestProfile()
+ with prof.group_manager(utils.Test, 'foo', run_concurrent=True) as g:
+ g(['a'], run_concurrent=False)
+
+ test = prof.test_list[grouptools.join('foo', 'a')]
+ nt.assert_equal(test.run_concurrent, False)