~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/per_bzrdir/__init__.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2010-09-01 08:02:42 UTC
  • mfrom: (5390.3.3 faster-revert-593560)
  • Revision ID: pqm@pqm.ubuntu.com-20100901080242-esg62ody4frwmy66
(spiv) Avoid repeatedly calling self.target.all_file_ids() in
 InterTree.iter_changes. (Andrew Bennetts)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2010 Canonical Ltd
2
 
# Authors: Robert Collins <robert.collins@canonical.com>
3
 
#          Jelmer Vernooij <jelmer.vernooij@canonical.com>
4
 
# -*- coding: utf-8 -*-
5
 
#
6
 
# This program is free software; you can redistribute it and/or modify
7
 
# it under the terms of the GNU General Public License as published by
8
 
# the Free Software Foundation; either version 2 of the License, or
9
 
# (at your option) any later version.
10
 
#
11
 
# This program is distributed in the hope that it will be useful,
12
 
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 
# GNU General Public License for more details.
15
 
#
16
 
# You should have received a copy of the GNU General Public License
17
 
# along with this program; if not, write to the Free Software
18
 
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
 
 
20
 
 
21
 
"""BzrDir implementation tests for bzr.
22
 
 
23
 
These test the conformance of all the bzrdir variations to the expected API.
24
 
Specific tests for individual formats are in the tests/test_bzrdir.py file
25
 
rather than in tests/per_branch/*.py. Generic control directory tests not
26
 
specific to BzrDir are in tests/per_controldir/*.py.
27
 
"""
28
 
 
29
 
from bzrlib.bzrdir import BzrDirFormat
30
 
from bzrlib.controldir import ControlDirFormat
31
 
from bzrlib.tests import (
32
 
    default_transport,
33
 
    multiply_tests,
34
 
    test_server,
35
 
    TestCaseWithTransport,
36
 
    )
37
 
from bzrlib.tests.per_controldir import make_scenarios
38
 
from bzrlib.transport import memory
39
 
 
40
 
 
41
 
class TestCaseWithBzrDir(TestCaseWithTransport):
42
 
 
43
 
    def setUp(self):
44
 
        super(TestCaseWithBzrDir, self).setUp()
45
 
        self.bzrdir = None
46
 
 
47
 
    def get_bzrdir(self):
48
 
        if self.bzrdir is None:
49
 
            self.bzrdir = self.make_bzrdir(None)
50
 
        return self.bzrdir
51
 
 
52
 
    def get_default_format(self):
53
 
        return self.bzrdir_format
54
 
 
55
 
 
56
 
def load_tests(standard_tests, module, loader):
57
 
    test_per_bzrdir = [
58
 
        'bzrlib.tests.per_bzrdir.test_bzrdir',
59
 
        ]
60
 
    submod_tests = loader.loadTestsFromModuleNames(test_per_bzrdir)
61
 
    formats = [format for format in ControlDirFormat.known_formats()
62
 
               if isinstance(format, BzrDirFormat)]
63
 
    scenarios = make_scenarios(
64
 
        default_transport,
65
 
        None,
66
 
        # None here will cause a readonly decorator to be created
67
 
        # by the TestCaseWithTransport.get_readonly_transport method.
68
 
        None,
69
 
        formats)
70
 
    # This will always add scenarios using the smart server.
71
 
    from bzrlib.remote import RemoteBzrDirFormat
72
 
    # test the remote server behaviour when backed with a MemoryTransport
73
 
    # Once for the current version
74
 
    scenarios.extend(make_scenarios(
75
 
        memory.MemoryServer,
76
 
        test_server.SmartTCPServer_for_testing,
77
 
        test_server.ReadonlySmartTCPServer_for_testing,
78
 
        [(RemoteBzrDirFormat())],
79
 
        name_suffix='-default'))
80
 
    # And once with < 1.6 - the 'v2' protocol.
81
 
    scenarios.extend(make_scenarios(
82
 
        memory.MemoryServer,
83
 
        test_server.SmartTCPServer_for_testing_v2_only,
84
 
        test_server.ReadonlySmartTCPServer_for_testing_v2_only,
85
 
        [(RemoteBzrDirFormat())],
86
 
        name_suffix='-v2'))
87
 
    # add the tests for the sub modules
88
 
    return multiply_tests(submod_tests, scenarios, standard_tests)