~testtools-committers/testscenarios/trunk

« back to all changes in this revision

Viewing changes to lib/testscenarios/scenarios.py

  • Committer: Robert Collins
  • Date: 2015-05-04 00:12:16 UTC
  • Revision ID: robertc@robertcollins.net-20150504001216-ff26ybf0lrejmr2s
0.4
~~~

IMPROVEMENTS
------------

* Python 3.2 support added. (Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
from testtools import iterate_tests
35
35
 
36
36
 
37
 
def apply_scenario((name, parameters), test):
 
37
def apply_scenario(scenario, test):
38
38
    """Apply scenario to test.
39
39
 
40
40
    :param scenario: A tuple (name, parameters) to apply to the test. The test
43
43
    :param test: The test to apply the scenario to. This test is unaltered.
44
44
    :return: A new test cloned from test, with the scenario applied.
45
45
    """
 
46
    name, parameters = scenario
46
47
    scenario_suffix = '(' + name + ')'
47
48
    newtest = clone_test_with_new_id(test,
48
49
        test.id() + scenario_suffix)
50
51
    if test_desc is not None:
51
52
        newtest_desc = "%(test_desc)s %(scenario_suffix)s" % vars()
52
53
        newtest.shortDescription = (lambda: newtest_desc)
53
 
    for key, value in parameters.iteritems():
 
54
    for key, value in parameters.items():
54
55
        setattr(newtest, key, value)
55
56
    return newtest
56
57