/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: Gustav Hartvigsson
  • Date: 2021-01-09 21:36:27 UTC
  • Revision ID: gustav.hartvigsson@gmail.com-20210109213627-h1xwcutzy9m7a99b
Added 'Case Preserving Working Tree Use Cases' from Canonical Wiki

* Addod a page from the Canonical Bazaar wiki
  with information on the scmeatics of case
  perserving filesystems an a case insensitive
  filesystem works.
  
  * Needs re-work, but this will do as it is the
    same inforamoton as what was on the linked
    page in the currint documentation.

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
 
    )
35
31
 
36
32
 
37
33
class TestErrors(tests.TestCase):
49
45
            init = getattr(c, '__init__', None)
50
46
            fmt = getattr(c, '_fmt', None)
51
47
            if init:
52
 
                if PY3:
53
 
                    args = inspect.getfullargspec(init)[0]
54
 
                else:
55
 
                    args = inspect.getargspec(init)[0]
 
48
                args = inspect.getfullargspec(init)[0]
56
49
                self.assertFalse('message' in args,
57
50
                                 ('Argument name "message" not allowed for '
58
51
                                  '"errors.%s.__init__"' % c.__name__))
67
60
            "^Filename b?'bad/filen\\\\xe5me' is not valid in your current"
68
61
            " filesystem encoding UTF-8$")
69
62
 
70
 
    def test_duplicate_file_id(self):
71
 
        error = errors.DuplicateFileId('a_file_id', 'foo')
72
 
        self.assertEqualDiff('File id {a_file_id} already exists in inventory'
73
 
                             ' as foo', str(error))
74
 
 
75
63
    def test_duplicate_help_prefix(self):
76
64
        error = errors.DuplicateHelpPrefix('foo')
77
65
        self.assertEqualDiff('The prefix foo is in the help search path twice.',
125
113
        self.assertEqual("Invalid range access in path at 12: bad range",
126
114
                         str(error))
127
115
 
128
 
    def test_inventory_modified(self):
129
 
        error = errors.InventoryModified("a tree to be repred")
130
 
        self.assertEqualDiff("The current inventory for the tree 'a tree to "
131
 
                             "be repred' has been modified, so a clean inventory cannot be "
132
 
                             "read without data loss.",
133
 
                             str(error))
134
 
 
135
116
    def test_jail_break(self):
136
117
        error = errors.JailBreak("some url")
137
118
        self.assertEqualDiff("An attempt to access a url outside the server"
199
180
                             "the currently open request.",
200
181
                             str(error))
201
182
 
202
 
    def test_unavailable_representation(self):
203
 
        error = errors.UnavailableRepresentation(
204
 
            ('key',), "mpdiff", "fulltext")
205
 
        self.assertEqualDiff("The encoding 'mpdiff' is not available for key "
206
 
                             "('key',) which is encoded as 'fulltext'.",
207
 
                             str(error))
208
 
 
209
183
    def test_unstackable_location(self):
210
184
        error = errors.UnstackableLocationError('foo', 'bar')
211
185
        self.assertEqualDiff("The branch 'foo' cannot be stacked on 'bar'.",
365
339
        e = errors.DuplicateRecordNameError(b"n\xc3\xa5me")
366
340
        self.assertEqual(
367
341
            u"Container has multiple records with the same name: n\xe5me",
368
 
            text_type(e))
 
342
            str(e))
369
343
 
370
344
    def test_check_error(self):
371
345
        e = errors.BzrCheckError('example check failure')
388
362
            "you wish to keep, and delete it when you are done.",
389
363
            str(err))
390
364
 
391
 
    def test_unable_create_symlink(self):
392
 
        err = errors.UnableCreateSymlink()
393
 
        self.assertEqual(
394
 
            "Unable to create symlink on this platform",
395
 
            str(err))
396
 
        err = errors.UnableCreateSymlink(path=u'foo')
397
 
        self.assertEqual(
398
 
            "Unable to create symlink 'foo' on this platform",
399
 
            str(err))
400
 
        err = errors.UnableCreateSymlink(path=u'\xb5')
401
 
        self.assertEqual(
402
 
            "Unable to create symlink %s on this platform" % repr(u'\xb5'),
403
 
            str(err))
404
 
 
405
365
    def test_invalid_url_join(self):
406
366
        """Test the formatting of InvalidURLJoin."""
407
367
        e = urlutils.InvalidURLJoin('Reason', 'base path', ('args',))
423
383
        err = errors.TipChangeRejected(u'Unicode message\N{INTERROBANG}')
424
384
        self.assertEqual(
425
385
            u'Tip change rejected: Unicode message\N{INTERROBANG}',
426
 
            text_type(err))
 
386
            str(err))
427
387
 
428
388
    def test_error_from_smart_server(self):
429
389
        error_tuple = ('error', 'tuple')
522
482
        # Unicode error, because it tries to call str() on the string
523
483
        # returned from e.__str__(), and it has non ascii characters
524
484
        s = str(e)
525
 
        if PY3:
526
 
            self.assertEqual('Pass through \xb5 and bar', s)
527
 
        else:
528
 
            self.assertEqual('Pass through \xc2\xb5 and bar', s)
 
485
        self.assertEqual('Pass through \xb5 and bar', s)
529
486
 
530
487
    def test_missing_format_string(self):
531
488
        e = ErrorWithNoFormat(param='randomvalue')
548
505
            str(e),
549
506
            r'Cannot bind address "example\.com:22":.*Permission denied')
550
507
 
551
 
    def test_transform_rename_failed(self):
552
 
        e = errors.TransformRenameFailed(u"from", u"to", "readonly file", 2)
553
 
        self.assertEqual(
554
 
            u"Failed to rename from to to: readonly file",
555
 
            str(e))
556
 
 
557
508
 
558
509
class TestErrorsUsingTransport(tests.TestCaseWithMemoryTransport):
559
510
    """Tests for errors that need to use a branch or repo."""