2
2
# dependency injection ('scenarios') by tests.
4
4
# Copyright (c) 2009, Robert Collins <robertc@robertcollins.net>
5
# Copyright (c) 2010 Martin Pool <mbp@sourcefrog.net>
6
7
# Licensed under either the Apache License, Version 2.0 or the BSD 3-clause
7
8
# license at the users choice. A copy of both licenses are available in the
171
174
tests = list(apply_scenarios(ReferenceTest.scenarios, test))
172
175
self.assertEqual([('demo', {})], ReferenceTest.scenarios)
173
176
self.assertEqual(ReferenceTest.scenarios, tests[0].scenarios)
179
class TestLoadTests(testtools.TestCase):
181
class SampleTest(unittest.TestCase):
182
def test_nothing(self):
189
def test_load_tests_apply_scenarios(self):
190
suite = load_tests_apply_scenarios(
191
unittest.TestLoader(),
192
[self.SampleTest('test_nothing')],
194
result_tests = list(testtools.iterate_tests(suite))
200
def test_load_tests_apply_scenarios_old_style(self):
201
"""Call load_tests in the way used by bzr."""
202
suite = load_tests_apply_scenarios(
203
[self.SampleTest('test_nothing')],
204
self.__class__.__module__,
205
unittest.TestLoader(),
207
result_tests = list(testtools.iterate_tests(suite))
214
class TestMultiplyScenarios(testtools.TestCase):
216
def test_multiply_scenarios(self):
220
scenarios = multiply_scenarios(factory('p'), factory('q'))
222
('a,a', dict(p='a', q='a')),
223
('a,b', dict(p='a', q='b')),
224
('b,a', dict(p='b', q='a')),
225
('b,b', dict(p='b', q='b')),
229
def test_multiply_many_scenarios(self):
233
scenarios = multiply_scenarios(factory('p'), factory('q'),
234
factory('r'), factory('t'))