~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_ui.py

(gz) Fix test failure on alpha by correcting format string for
 gc_chk_sha1_record (Martin [gz])

Show diffs side-by-side

added added

removed removed

Lines of Context:
63
63
    def test_text_factory_confirm(self):
64
64
        # turns into reading a regular boolean
65
65
        ui = self.make_test_ui_factory('n\n')
66
 
        self.assertEquals(ui.confirm_action(u'Should %(thing)s pass?',
 
66
        self.assertEquals(ui.confirm_action('Should %(thing)s pass?',
67
67
            'bzrlib.tests.test_ui.confirmation',
68
68
            {'thing': 'this'},),
69
69
            False)
119
119
        stdout = tests.StringIOWrapper()
120
120
        stderr = tests.StringIOWrapper()
121
121
        factory = _mod_ui_text.TextUIFactory(stdin, stdout, stderr)
122
 
        self.assertEqual(True, factory.get_boolean(u""))
123
 
        self.assertEqual(False, factory.get_boolean(u""))
124
 
        self.assertEqual(True, factory.get_boolean(u""))
125
 
        self.assertEqual(False, factory.get_boolean(u""))
126
 
        self.assertEqual(True, factory.get_boolean(u""))
127
 
        self.assertEqual(False, factory.get_boolean(u""))
 
122
        self.assertEqual(True, factory.get_boolean(""))
 
123
        self.assertEqual(False, factory.get_boolean(""))
 
124
        self.assertEqual(True, factory.get_boolean(""))
 
125
        self.assertEqual(False, factory.get_boolean(""))
 
126
        self.assertEqual(True, factory.get_boolean(""))
 
127
        self.assertEqual(False, factory.get_boolean(""))
128
128
        self.assertEqual("foo\n", factory.stdin.read())
129
129
        # stdin should be empty
130
130
        self.assertEqual('', factory.stdin.readline())
137
137
        stdout = tests.StringIOWrapper()
138
138
        stderr = tests.StringIOWrapper()
139
139
        factory = _mod_ui_text.TextUIFactory(stdin, stdout, stderr)
140
 
        self.assertEqual(1, factory.get_integer(u""))
141
 
        self.assertEqual(-2, factory.get_integer(u""))
142
 
        self.assertEqual(42, factory.get_integer(u""))
 
140
        self.assertEqual(1, factory.get_integer(""))
 
141
        self.assertEqual(-2, factory.get_integer(""))
 
142
        self.assertEqual(42, factory.get_integer(""))
143
143
 
144
144
    def test_text_factory_prompt(self):
145
145
        # see <https://launchpad.net/bugs/365891>
146
146
        StringIO = tests.StringIOWrapper
147
147
        factory = _mod_ui_text.TextUIFactory(StringIO(), StringIO(), StringIO())
148
 
        factory.prompt(u'foo %2e')
 
148
        factory.prompt('foo %2e')
149
149
        self.assertEqual('', factory.stdout.getvalue())
150
150
        self.assertEqual('foo %2e', factory.stderr.getvalue())
151
151
 
166
166
                         self.apply_redirected(None, factory.stdout,
167
167
                                               factory.stdout,
168
168
                                               factory.get_boolean,
169
 
                                               u"what do you want"))
 
169
                                               "what do you want"))
170
170
        output = out.getvalue()
171
171
        self.assertContainsRe(output,
172
172
            "| foo *\r\r  *\r*")
195
195
        factory.stdout.encoding = "utf8"
196
196
        # there is no output from the base factory
197
197
        self.assertEqual("someuser",
198
 
                         factory.get_username(u'Hello %(host)s', host='some'))
 
198
                         factory.get_username('Hello %(host)s', host='some'))
199
199
        self.assertEquals("Hello some: ", factory.stderr.getvalue())
200
200
        self.assertEquals('', factory.stdout.getvalue())
201
 
        self.assertEqual("", factory.get_username(u"Gebruiker"))
 
201
        self.assertEqual("", factory.get_username("Gebruiker"))
202
202
        # stdin should be empty
203
203
        self.assertEqual('', factory.stdin.readline())
204
204
 
232
232
 
233
233
    def test_text_ui_show_user_warning(self):
234
234
        from bzrlib.repofmt.groupcompress_repo import RepositoryFormat2a
235
 
        from bzrlib.repofmt.knitpack_repo import RepositoryFormatKnitPack5
 
235
        from bzrlib.repofmt.pack_repo import RepositoryFormatKnitPack5
236
236
        err = StringIO()
237
237
        out = StringIO()
238
238
        ui = tests.TextUIFactory(stdin=None, stdout=out, stderr=err)
352
352
        self.assertRaises(
353
353
            NotImplementedError,
354
354
            self.apply_redirected,
355
 
            None, stdout, stdout, factory.get_boolean, u"foo")
 
355
            None, stdout, stdout, factory.get_boolean, "foo")
356
356
 
357
357
 
358
358
class TestUIFactoryTests(tests.TestCase):
371
371
 
372
372
    def test_canned_input_get_input(self):
373
373
        uif = _mod_ui.CannedInputUIFactory([True, 'mbp', 'password', 42])
374
 
        self.assertEqual(True, uif.get_boolean(u'Extra cheese?'))
375
 
        self.assertEqual('mbp', uif.get_username(u'Enter your user name'))
 
374
        self.assertEqual(True, uif.get_boolean('Extra cheese?'))
 
375
        self.assertEqual('mbp', uif.get_username('Enter your user name'))
376
376
        self.assertEqual('password',
377
 
                         uif.get_password(u'Password for %(host)s',
 
377
                         uif.get_password('Password for %(host)s',
378
378
                                          host='example.com'))
379
 
        self.assertEqual(42, uif.get_integer(u'And all that jazz ?'))
 
379
        self.assertEqual(42, uif.get_integer('And all that jazz ?'))
380
380
 
381
381
 
382
382
class TestBoolFromString(tests.TestCase):