~jayvdb/testscenarios/0.4

« back to all changes in this revision

Viewing changes to lib/testscenarios/tests/test_scenarios.py

  • Committer: Martin Pool
  • Date: 2010-10-12 04:50:57 UTC
  • mto: This revision was merged to the branch mainline in revision 18.
  • Revision ID: mbp@sourcefrog.net-20101012045057-9hzwooq8tj8ckjse
Add multiply_scenarios

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
    apply_scenarios,
24
24
    generate_scenarios,
25
25
    load_tests_apply_scenarios,
 
26
    multiply_scenarios,
26
27
    )
27
28
import testtools
28
29
from testtools.tests.helpers import LoggingResult
211
212
            2,
212
213
            len(result_tests),
213
214
            result_tests)
 
215
 
 
216
 
 
217
class TestMultiplyScenarios(testtools.TestCase):
 
218
 
 
219
    def test_multiply_scenarios(self):
 
220
        def s(name):
 
221
            for i in 'ab':
 
222
                yield i, {name: i}
 
223
        r = list(multiply_scenarios(s('p'), s('q')))
 
224
        self.assertEquals([
 
225
            ('a,a', dict(p='a', q='a')),
 
226
            ('a,b', dict(p='a', q='b')),
 
227
            ('b,a', dict(p='b', q='a')),
 
228
            ('b,b', dict(p='b', q='b')),
 
229
            ],
 
230
            r)
 
231
 
 
232
    def test_multiply_many_scenarios(self):
 
233
        def s(name):
 
234
            for i in 'abc':
 
235
                yield i, {name: i}
 
236
        r = list(multiply_scenarios(s('p'), s('q'), s('r'), s('t')))
 
237
        self.assertEqual(
 
238
            3**4,
 
239
            len(r),
 
240
            r)
 
241
        self.assertEqual(
 
242
            'a,a,a,a',
 
243
            r[0][0])