/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

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

  • Committer: Robert Collins
  • Date: 2008-08-20 02:07:36 UTC
  • mfrom: (3640 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3682.
  • Revision ID: robertc@robertcollins.net-20080820020736-g2xe4921zzxtymle
Merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006 by Canonical Ltd
2
 
# -*- coding: utf-8 -*-
3
 
 
 
1
# Copyright (C) 2005, 2006, 2007 Canonical Ltd
 
2
#
4
3
# This program is free software; you can redistribute it and/or modify
5
4
# it under the terms of the GNU General Public License as published by
6
5
# the Free Software Foundation; either version 2 of the License, or
7
6
# (at your option) any later version.
8
 
 
 
7
#
9
8
# This program is distributed in the hope that it will be useful,
10
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
11
# GNU General Public License for more details.
13
 
 
 
12
#
14
13
# You should have received a copy of the GNU General Public License
15
14
# along with this program; if not, write to the Free Software
16
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
28
27
from bzrlib.tests import (
29
28
                          adapt_modules,
30
29
                          TestCaseWithTransport,
31
 
                          TestSuite,
32
 
                          TestLoader,
33
30
                          iter_suite_tests,
34
31
                          )
35
32
from bzrlib.tests.EncodingAdapter import EncodingTestAdapter
 
33
from bzrlib.symbol_versioning import (
 
34
    deprecated_method,
 
35
    )
36
36
import bzrlib.ui as ui
37
37
 
38
38
 
39
 
def test_suite():
 
39
def load_tests(basic_tests, module, loader):
 
40
    suite = loader.suiteClass()
 
41
    # add the tests for this module
 
42
    suite.addTests(basic_tests)
 
43
 
40
44
    testmod_names = [
41
45
                     'bzrlib.tests.blackbox.test_add',
42
46
                     'bzrlib.tests.blackbox.test_added',
 
47
                     'bzrlib.tests.blackbox.test_alias',
43
48
                     'bzrlib.tests.blackbox.test_aliases',
44
49
                     'bzrlib.tests.blackbox.test_ancestry',
45
50
                     'bzrlib.tests.blackbox.test_annotate',
46
51
                     'bzrlib.tests.blackbox.test_branch',
47
52
                     'bzrlib.tests.blackbox.test_break_lock',
 
53
                     'bzrlib.tests.blackbox.test_breakin',
48
54
                     'bzrlib.tests.blackbox.test_bound_branches',
 
55
                     'bzrlib.tests.blackbox.test_bundle_info',
49
56
                     'bzrlib.tests.blackbox.test_cat',
 
57
                     'bzrlib.tests.blackbox.test_cat_revision',
 
58
                     'bzrlib.tests.blackbox.test_check',
50
59
                     'bzrlib.tests.blackbox.test_checkout',
51
60
                     'bzrlib.tests.blackbox.test_command_encoding',
52
61
                     'bzrlib.tests.blackbox.test_commit',
53
62
                     'bzrlib.tests.blackbox.test_conflicts',
 
63
                     'bzrlib.tests.blackbox.test_debug',
54
64
                     'bzrlib.tests.blackbox.test_diff',
 
65
                     'bzrlib.tests.blackbox.test_exceptions',
55
66
                     'bzrlib.tests.blackbox.test_export',
56
67
                     'bzrlib.tests.blackbox.test_find_merge_base',
57
68
                     'bzrlib.tests.blackbox.test_help',
 
69
                     'bzrlib.tests.blackbox.test_hooks',
 
70
                     'bzrlib.tests.blackbox.test_ignore',
58
71
                     'bzrlib.tests.blackbox.test_ignored',
59
72
                     'bzrlib.tests.blackbox.test_info',
60
73
                     'bzrlib.tests.blackbox.test_init',
 
74
                     'bzrlib.tests.blackbox.test_inventory',
 
75
                     'bzrlib.tests.blackbox.test_join',
 
76
                     'bzrlib.tests.blackbox.test_locale',
61
77
                     'bzrlib.tests.blackbox.test_log',
62
78
                     'bzrlib.tests.blackbox.test_logformats',
 
79
                     'bzrlib.tests.blackbox.test_ls',
 
80
                     'bzrlib.tests.blackbox.test_lsprof',
63
81
                     'bzrlib.tests.blackbox.test_merge',
 
82
                     'bzrlib.tests.blackbox.test_merge_directive',
64
83
                     'bzrlib.tests.blackbox.test_missing',
 
84
                     'bzrlib.tests.blackbox.test_modified',
 
85
                     'bzrlib.tests.blackbox.test_mv',
 
86
                     'bzrlib.tests.blackbox.test_nick',
65
87
                     'bzrlib.tests.blackbox.test_outside_wt',
 
88
                     'bzrlib.tests.blackbox.test_pack',
66
89
                     'bzrlib.tests.blackbox.test_pull',
67
90
                     'bzrlib.tests.blackbox.test_push',
68
91
                     'bzrlib.tests.blackbox.test_reconcile',
 
92
                     'bzrlib.tests.blackbox.test_reconfigure',
 
93
                     'bzrlib.tests.blackbox.test_remerge',
69
94
                     'bzrlib.tests.blackbox.test_remove',
70
95
                     'bzrlib.tests.blackbox.test_re_sign',
 
96
                     'bzrlib.tests.blackbox.test_remove_tree',
71
97
                     'bzrlib.tests.blackbox.test_revert',
72
98
                     'bzrlib.tests.blackbox.test_revno',
 
99
                     'bzrlib.tests.blackbox.test_revision_history',
73
100
                     'bzrlib.tests.blackbox.test_revision_info',
74
101
                     'bzrlib.tests.blackbox.test_selftest',
 
102
                     'bzrlib.tests.blackbox.test_send',
 
103
                     'bzrlib.tests.blackbox.test_serve',
75
104
                     'bzrlib.tests.blackbox.test_shared_repository',
76
105
                     'bzrlib.tests.blackbox.test_sign_my_commits',
 
106
                     'bzrlib.tests.blackbox.test_split',
77
107
                     'bzrlib.tests.blackbox.test_status',
 
108
                     'bzrlib.tests.blackbox.test_switch',
 
109
                     'bzrlib.tests.blackbox.test_tags',
 
110
                     'bzrlib.tests.blackbox.test_testament',
78
111
                     'bzrlib.tests.blackbox.test_too_much',
79
112
                     'bzrlib.tests.blackbox.test_uncommit',
 
113
                     'bzrlib.tests.blackbox.test_unknowns',
80
114
                     'bzrlib.tests.blackbox.test_update',
81
115
                     'bzrlib.tests.blackbox.test_upgrade',
 
116
                     'bzrlib.tests.blackbox.test_version',
 
117
                     'bzrlib.tests.blackbox.test_version_info',
82
118
                     'bzrlib.tests.blackbox.test_versioning',
 
119
                     'bzrlib.tests.blackbox.test_whoami',
83
120
                     ]
 
121
    # add the tests for the sub modules
 
122
    suite.addTests(loader.loadTestsFromModuleNames(testmod_names))
 
123
 
84
124
    test_encodings = [
85
125
        'bzrlib.tests.blackbox.test_non_ascii',
86
126
    ]
87
127
 
88
 
    loader = TestLoader()
89
 
    suite = loader.loadTestsFromModuleNames(testmod_names) 
90
 
 
91
128
    adapter = EncodingTestAdapter()
92
129
    adapt_modules(test_encodings, adapter, loader, suite)
93
130
 
96
133
 
97
134
class ExternalBase(TestCaseWithTransport):
98
135
 
99
 
    def runbzr(self, args, retcode=0, backtick=False):
100
 
        if isinstance(args, basestring):
101
 
            args = args.split()
102
 
        if backtick:
103
 
            return self.run_bzr_captured(args, retcode=retcode)[0]
104
 
        else:
105
 
            return self.run_bzr_captured(args, retcode=retcode)
106
 
 
107
 
 
108
 
class TestUIFactory(ui.CLIUIFactory):
109
 
    """A UI Factory for testing - hide the progress bar but emit note()s."""
110
 
 
111
 
    def __init__(self,
112
 
                 stdout=None,
113
 
                 stderr=None):
114
 
        super(TestUIFactory, self).__init__()
115
 
        if stdout is None:
116
 
            self.stdout = sys.stdout
117
 
        else:
118
 
            self.stdout = stdout
119
 
        if stderr is None:
120
 
            self.stderr = sys.stderr
121
 
        else:
122
 
            self.stderr = stderr
123
 
 
124
 
    def clear(self):
125
 
        """See progress.ProgressBar.clear()."""
126
 
 
127
 
    def clear_term(self):
128
 
        """See progress.ProgressBar.clear_term()."""
129
 
 
130
 
    def clear_term(self):
131
 
        """See progress.ProgressBar.clear_term()."""
132
 
 
133
 
    def finished(self):
134
 
        """See progress.ProgressBar.finished()."""
135
 
 
136
 
    def note(self, fmt_string, *args, **kwargs):
137
 
        """See progress.ProgressBar.note()."""
138
 
        self.stdout.write((fmt_string + "\n") % args)
139
 
 
140
 
    def progress_bar(self):
141
 
        return self
142
 
    
143
 
    def nested_progress_bar(self):
144
 
        return self
145
 
 
146
 
    def update(self, message, count=None, total=None):
147
 
        """See progress.ProgressBar.update()."""
 
136
    def check_output(self, output, *args):
 
137
        """Verify that the expected output matches what bzr says.
 
138
 
 
139
        The output is supplied first, so that you can supply a variable
 
140
        number of arguments to bzr.
 
141
        """
 
142
        self.assertEquals(self.run_bzr(*args)[0], output)