~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_ui.py

  • Committer: Vincent Ladeuil
  • Date: 2016-02-01 18:09:18 UTC
  • mfrom: (6614.1.3 assert)
  • mto: This revision was merged to the branch mainline in revision 6615.
  • Revision ID: v.ladeuil+lp@free.fr-20160201180918-jqtq8ol6gdbbbtpv
Fix deprecated assertions to unblock release

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005-2011 Canonical Ltd
 
1
# Copyright (C) 2005-2012, 2016 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
61
61
            stdout=tests.StringIOWrapper(),
62
62
            stderr=tests.StringIOWrapper())
63
63
        output = ui.make_output_stream()
64
 
        self.assertEquals(output.encoding, enc)
 
64
        self.assertEqual(output.encoding, enc)
65
65
 
66
66
 
67
67
class TestTextUIFactory(tests.TestCase):
75
75
    def test_text_factory_confirm(self):
76
76
        # turns into reading a regular boolean
77
77
        ui = self.make_test_ui_factory('n\n')
78
 
        self.assertEquals(ui.confirm_action(u'Should %(thing)s pass?',
 
78
        self.assertEqual(ui.confirm_action(u'Should %(thing)s pass?',
79
79
            'bzrlib.tests.test_ui.confirmation',
80
80
            {'thing': 'this'},),
81
81
            False)
268
268
        ui.stdout.encoding = 'utf8'
269
269
        self.assertEqual('someuser',
270
270
                         ui.get_username(u'Hello %(host)s', host='some'))
271
 
        self.assertEquals('Hello some: ', ui.stderr.getvalue())
272
 
        self.assertEquals('', ui.stdout.getvalue())
 
271
        self.assertEqual('Hello some: ', ui.stderr.getvalue())
 
272
        self.assertEqual('', ui.stdout.getvalue())
273
273
        self.assertEqual('', ui.get_username(u"Gebruiker"))
274
274
        # stdin should be empty
275
275
        self.assertEqual('', ui.stdin.readline())
281
281
        ui.stderr = tests.StringIOWrapper()
282
282
        ui.stderr.encoding = ui.stdout.encoding = ui.stdin.encoding = "utf8"
283
283
        username = ui.get_username(u'Hello %(host)s', host=u'some\u1234')
284
 
        self.assertEquals(u"someuser\u1234", username)
285
 
        self.assertEquals(u"Hello some\u1234: ",
 
284
        self.assertEqual(u"someuser\u1234", username)
 
285
        self.assertEqual(u"Hello some\u1234: ",
286
286
                          ui.stderr.getvalue().decode("utf8"))
287
 
        self.assertEquals('', ui.stdout.getvalue())
 
287
        self.assertEqual('', ui.stdout.getvalue())
288
288
 
289
289
    def test_quietness(self):
290
290
        self.overrideEnv('BZR_PROGRESS_BAR', 'text')
307
307
        remote_fmt._network_name = RepositoryFormatKnitPack5().network_name()
308
308
        ui.show_user_warning('cross_format_fetch', from_format=RepositoryFormat2a(),
309
309
            to_format=remote_fmt)
310
 
        self.assertEquals('', out.getvalue())
311
 
        self.assertEquals("Doing on-the-fly conversion from RepositoryFormat2a() to "
 
310
        self.assertEqual('', out.getvalue())
 
311
        self.assertEqual("Doing on-the-fly conversion from RepositoryFormat2a() to "
312
312
            "RemoteRepositoryFormat(_network_name='Bazaar RepositoryFormatKnitPack5 "
313
313
            "(bzr 1.6)\\n').\nThis may take some time. Upgrade the repositories to "
314
314
            "the same format for better performance.\n",
320
320
        ui.suppressed_warnings.add('cross_format_fetch')
321
321
        ui.show_user_warning('cross_format_fetch', from_format=RepositoryFormat2a(),
322
322
            to_format=remote_fmt)
323
 
        self.assertEquals('', out.getvalue())
324
 
        self.assertEquals('', err.getvalue())
 
323
        self.assertEqual('', out.getvalue())
 
324
        self.assertEqual('', err.getvalue())
325
325
 
326
326
 
327
327
class TestTextUIOutputStream(tests.TestCase):
449
449
 
450
450
    def assertIsTrue(self, s, accepted_values=None):
451
451
        res = _mod_ui.bool_from_string(s, accepted_values=accepted_values)
452
 
        self.assertEquals(True, res)
 
452
        self.assertEqual(True, res)
453
453
 
454
454
    def assertIsFalse(self, s, accepted_values=None):
455
455
        res = _mod_ui.bool_from_string(s, accepted_values=accepted_values)
456
 
        self.assertEquals(False, res)
 
456
        self.assertEqual(False, res)
457
457
 
458
458
    def assertIsNone(self, s, accepted_values=None):
459
459
        res = _mod_ui.bool_from_string(s, accepted_values=accepted_values)
506
506
    def test_confirm_action_default(self):
507
507
        base_ui = _mod_ui.NoninteractiveUIFactory()
508
508
        for answer in [True, False]:
509
 
            self.assertEquals(
 
509
            self.assertEqual(
510
510
                _mod_ui.ConfirmationUserInterfacePolicy(base_ui, answer, {})
511
511
                .confirm_action("Do something?",
512
512
                    "bzrlib.tests.do_something", {}),
521
521
                        base_ui, default_answer, dict(given_id=specific_answer))
522
522
                    result = wrapper.confirm_action("Do something?", conf_id, {})
523
523
                    if conf_id == 'given_id':
524
 
                        self.assertEquals(result, specific_answer)
 
524
                        self.assertEqual(result, specific_answer)
525
525
                    else:
526
 
                        self.assertEquals(result, default_answer)
 
526
                        self.assertEqual(result, default_answer)
527
527
 
528
528
    def test_repr(self):
529
529
        base_ui = _mod_ui.NoninteractiveUIFactory()