~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

(vila) Fix bzrlib.tests.test_gpg.TestVerify.test_verify_revoked_signature
 with recent versions of gpg. (Vincent Ladeuil)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2009, 2010 Canonical Ltd
 
1
# Copyright (C) 2009, 2010, 2011 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
62
62
        self.factory.be_quiet(False)
63
63
        self.assertEquals(False, self.factory.is_quiet())
64
64
 
 
65
    def test_confirm_action(self):
 
66
        # confirm_action should be answered by every ui factory; even
 
67
        # noninteractive ones should have a reasonable default
 
68
        self._load_responses([True])
 
69
        result = self.factory.confirm_action(u'Break a lock?',
 
70
             'bzr.lock.break.confirm',
 
71
            {})
 
72
        # will be true either because we read it from the input or because
 
73
        # that's the default
 
74
        self.assertEquals(result, True)
 
75
 
65
76
    def test_note(self):
66
77
        self.factory.note("a note to the user")
67
78
        self._check_note("a note to the user")
90
101
    def test_transport_activity(self):
91
102
        # It doesn't matter what the implementation does, we just want to make
92
103
        # sure the interface is there
93
 
        t = transport.get_transport('memory:///')
 
104
        t = transport.get_transport_from_url('memory:///')
94
105
        self.factory.report_transport_activity(t, 1000, 'write')
95
106
        self.factory.report_transport_activity(t, 2000, 'read')
96
107
        self.factory.report_transport_activity(t, 4000, None)
101
112
 
102
113
    def test_no_transport_activity(self):
103
114
        # No activity to report
104
 
        t = transport.get_transport('memory:///')
 
115
        t = transport.get_transport_from_url('memory:///')
105
116
        self.factory.log_transport_activity(display=True)
106
117
        self._check_log_transport_activity_display_no_bytes()
107
118
 
150
161
        # Without a TTY, we shouldn't display anything
151
162
        self.assertEqual('', self.stderr.getvalue())
152
163
 
 
164
    def _load_responses(self, responses):
 
165
        self.factory.stdin.seek(0)
 
166
        self.factory.stdin.writelines([(r and "y\n" or "n\n") for r in responses])
 
167
        self.factory.stdin.seek(0)
 
168
 
153
169
 
154
170
class TestTTYTextUIFactory(TestTextUIFactory):
155
171
 
173
189
 
174
190
        # Remove 'TERM' == 'dumb' which causes us to *not* treat output as a
175
191
        # real terminal, even though isatty returns True
176
 
        self._captureVar('TERM', None)
 
192
        self.overrideEnv('TERM', None)
177
193
        self.stderr = TTYStringIO()
178
194
        self.stdout = TTYStringIO()
179
195
        self.factory = ui.text.TextUIFactory(self.stdin, self.stdout,
222
238
    def _check_log_transport_activity_display_no_bytes(self):
223
239
        pass
224
240
 
 
241
    def _load_responses(self, responses):
 
242
        pass
 
243
 
225
244
 
226
245
class TestCannedInputUIFactory(tests.TestCase, UIFactoryTestMixin):
227
246
    # discards output, reads input from variables
250
269
 
251
270
    def _check_log_transport_activity_display_no_bytes(self):
252
271
        pass
 
272
 
 
273
    def _load_responses(self, responses):
 
274
        self.factory.responses.extend(responses)