~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:10:49 UTC
  • mto: This revision was merged to the branch mainline in revision 18.
  • Revision ID: mbp@sourcefrog.net-20101012041049-z553elkeihmrq27w
Support both python2.7 and bzr load_tests argument lists

Show diffs side-by-side

added added

removed removed

Lines of Context:
177
177
 
178
178
class TestLoadTests(testtools.TestCase):
179
179
 
 
180
    class SampleTest(unittest.TestCase):
 
181
        def test_nothing(self): 
 
182
            pass
 
183
        scenarios = [
 
184
            ('a', {}),
 
185
            ('b', {}),
 
186
            ]
 
187
 
180
188
    def test_load_tests_apply_scenarios(self):
181
 
        class SampleTest(unittest.TestCase):
182
 
            def test_nothing(self): 
183
 
                pass
184
 
            scenarios = [
185
 
                ('a', {}),
186
 
                ('b', {}),
187
 
                ]
188
189
        suite = load_tests_apply_scenarios(
189
190
            unittest.TestLoader(),
190
 
            [SampleTest('test_nothing')],
 
191
            [self.SampleTest('test_nothing')],
191
192
            None)
192
193
        result_tests = list(testtools.iterate_tests(suite))
193
194
        self.assertEquals(
194
195
            2,
195
196
            len(result_tests),
196
197
            result_tests)
 
198
 
 
199
    def test_load_tests_apply_scenarios_old_style(self):
 
200
        """Call load_tests in the way used by pre-Python2.7 code.
 
201
 
 
202
        See <https://bugs.launchpad.net/bzr/+bug/607412>
 
203
        """
 
204
        suite = load_tests_apply_scenarios(
 
205
            [self.SampleTest('test_nothing')],
 
206
            self.__class__.__module__,
 
207
            unittest.TestLoader(),
 
208
            )
 
209
        result_tests = list(testtools.iterate_tests(suite))
 
210
        self.assertEquals(
 
211
            2,
 
212
            len(result_tests),
 
213
            result_tests)