~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_variations.py

  • Committer: Martin Pool
  • Date: 2010-10-08 08:48:51 UTC
  • mto: This revision was merged to the branch mainline in revision 5483.
  • Revision ID: mbp@sourcefrog.net-20101008084851-6mc9svgakj7camqp
Add unite tests for variations

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2005-2010 Canonical Ltd
 
2
#
 
3
# This program is free software; you can redistribute it and/or modify
 
4
# it under the terms of the GNU General Public License as published by
 
5
# the Free Software Foundation; either version 2 of the License, or
 
6
# (at your option) any later version.
 
7
#
 
8
# This program is distributed in the hope that it will be useful,
 
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
# GNU General Public License for more details.
 
12
#
 
13
# You should have received a copy of the GNU General Public License
 
14
# along with this program; if not, write to the Free Software
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
16
 
 
17
from bzrlib.tests import (
 
18
    TestCase,
 
19
    TestLoader,
 
20
    iter_suite_tests,
 
21
    )
 
22
 
 
23
from bzrlib.tests.variations import (
 
24
    TestVariation,
 
25
    multiply_tests_by_variations,
 
26
    )
 
27
 
 
28
 
 
29
class SimpleVariation(TestVariation):
 
30
 
 
31
    def scenarios(self):
 
32
        return [
 
33
            ('a', {'value': 'a'}),
 
34
            ('b', {'value': 'b'})
 
35
        ]
 
36
 
 
37
 
 
38
class TestTestVariations(TestCase):
 
39
 
 
40
    def test_multiply_tests_by_variations(self):
 
41
        loader = TestLoader()
 
42
        suite = loader.suiteClass()
 
43
        multiply_tests_by_variations(
 
44
            self,
 
45
            [SimpleVariation()],
 
46
            suite)
 
47
        generated_tests = list(iter_suite_tests(suite))
 
48
        self.assertEquals(len(generated_tests), 2)
 
49
        self.assertEquals(
 
50
            sorted([t.value for t in generated_tests]),
 
51
            ['a', 'b'])