/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 breezy/tests/test_errors.py

  • Committer: Jelmer Vernooij
  • Date: 2020-07-05 12:50:01 UTC
  • mfrom: (7490.40.46 work)
  • mto: (7490.40.48 work)
  • mto: This revision was merged to the branch mainline in revision 7519.
  • Revision ID: jelmer@jelmer.uk-20200705125001-7s3vo0p55szbbws7
Merge lp:brz/3.1.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
    tests,
29
29
    urlutils,
30
30
    )
 
31
from ..sixish import (
 
32
    PY3,
 
33
    text_type,
 
34
    )
31
35
 
32
36
 
33
37
class TestErrors(tests.TestCase):
45
49
            init = getattr(c, '__init__', None)
46
50
            fmt = getattr(c, '_fmt', None)
47
51
            if init:
48
 
                args = inspect.getfullargspec(init)[0]
 
52
                if PY3:
 
53
                    args = inspect.getfullargspec(init)[0]
 
54
                else:
 
55
                    args = inspect.getargspec(init)[0]
49
56
                self.assertFalse('message' in args,
50
57
                                 ('Argument name "message" not allowed for '
51
58
                                  '"errors.%s.__init__"' % c.__name__))
339
346
        e = errors.DuplicateRecordNameError(b"n\xc3\xa5me")
340
347
        self.assertEqual(
341
348
            u"Container has multiple records with the same name: n\xe5me",
342
 
            str(e))
 
349
            text_type(e))
343
350
 
344
351
    def test_check_error(self):
345
352
        e = errors.BzrCheckError('example check failure')
383
390
        err = errors.TipChangeRejected(u'Unicode message\N{INTERROBANG}')
384
391
        self.assertEqual(
385
392
            u'Tip change rejected: Unicode message\N{INTERROBANG}',
386
 
            str(err))
 
393
            text_type(err))
387
394
 
388
395
    def test_error_from_smart_server(self):
389
396
        error_tuple = ('error', 'tuple')
482
489
        # Unicode error, because it tries to call str() on the string
483
490
        # returned from e.__str__(), and it has non ascii characters
484
491
        s = str(e)
485
 
        self.assertEqual('Pass through \xb5 and bar', s)
 
492
        if PY3:
 
493
            self.assertEqual('Pass through \xb5 and bar', s)
 
494
        else:
 
495
            self.assertEqual('Pass through \xc2\xb5 and bar', s)
486
496
 
487
497
    def test_missing_format_string(self):
488
498
        e = ErrorWithNoFormat(param='randomvalue')