133
133
error = errors.InvalidHttpRange('path',
134
134
'Content-Range: potatoes 0-00/o0oo0',
136
self.assertEquals("Invalid http range"
137
" 'Content-Range: potatoes 0-00/o0oo0'"
138
" for path: bad range",
136
self.assertEqual("Invalid http range"
137
" 'Content-Range: potatoes 0-00/o0oo0'"
138
" for path: bad range",
141
141
def test_invalid_range(self):
142
142
error = errors.InvalidRange('path', 12, 'bad range')
143
self.assertEquals("Invalid range access in path at 12: bad range",
143
self.assertEqual("Invalid range access in path at 12: bad range",
146
146
def test_inventory_modified(self):
147
147
error = errors.InventoryModified("a tree to be repred")
518
518
def test_immortal_pending_deletion_message(self):
519
519
err = errors.ImmortalPendingDeletion('foo')
521
521
"Unable to delete transform temporary directory foo. "
522
522
"Please examine foo to see if it contains any files "
523
523
"you wish to keep, and delete it when you are done.",
526
526
def test_unable_create_symlink(self):
527
527
err = errors.UnableCreateSymlink()
529
529
"Unable to create symlink on this platform",
531
531
err = errors.UnableCreateSymlink(path=u'foo')
533
533
"Unable to create symlink 'foo' on this platform",
535
535
err = errors.UnableCreateSymlink(path=u'\xb5')
537
537
"Unable to create symlink u'\\xb5' on this platform",
547
547
def test_incorrect_url(self):
548
548
err = errors.InvalidBugTrackerURL('foo', 'http://bug.com/')
550
550
("The URL for bug tracker \"foo\" doesn't contain {id}: "
551
551
"http://bug.com/"),
554
554
def test_unable_encode_path(self):
555
555
err = errors.UnableEncodePath('foo', 'executable')
556
self.assertEquals("Unable to encode executable path 'foo' in "
557
"user encoding " + osutils.get_user_encoding(),
556
self.assertEqual("Unable to encode executable path 'foo' in "
557
"user encoding " + osutils.get_user_encoding(),
560
560
def test_unknown_format(self):
561
561
err = errors.UnknownFormatError('bar', kind='foo')
562
self.assertEquals("Unknown foo format: 'bar'", str(err))
562
self.assertEqual("Unknown foo format: 'bar'", str(err))
564
564
def test_unknown_rules(self):
565
565
err = errors.UnknownRules(['foo', 'bar'])
566
self.assertEquals("Unknown rules detected: foo, bar.", str(err))
566
self.assertEqual("Unknown rules detected: foo, bar.", str(err))
568
568
def test_tip_change_rejected(self):
569
569
err = errors.TipChangeRejected(u'Unicode message\N{INTERROBANG}')
571
571
u'Tip change rejected: Unicode message\N{INTERROBANG}',
574
574
'Tip change rejected: Unicode message\xe2\x80\xbd',
577
577
def test_error_from_smart_server(self):
578
578
error_tuple = ('error', 'tuple')
579
579
err = errors.ErrorFromSmartServer(error_tuple)
581
581
"Error received from smart server: ('error', 'tuple')", str(err))
583
583
def test_untranslateable_error_from_smart_server(self):
584
584
error_tuple = ('error', 'tuple')
585
585
orig_err = errors.ErrorFromSmartServer(error_tuple)
586
586
err = errors.UnknownErrorFromSmartServer(orig_err)
588
588
"Server sent an unexpected error: ('error', 'tuple')", str(err))
590
590
def test_smart_message_handler_error(self):
609
609
def test_no_such_view(self):
610
610
err = errors.NoSuchView('foo')
611
self.assertEquals("No such view: foo.", str(err))
611
self.assertEqual("No such view: foo.", str(err))
613
613
def test_views_not_supported(self):
614
614
err = errors.ViewsNotSupported('atree')
620
620
def test_file_outside_view(self):
621
621
err = errors.FileOutsideView('baz', ['foo', 'bar'])
622
self.assertEquals('Specified file "baz" is outside the current view: '
623
'foo, bar', str(err))
622
self.assertEqual('Specified file "baz" is outside the current view: '
623
'foo, bar', str(err))
625
625
def test_invalid_shelf_id(self):
626
626
invalid_id = "foo"
627
627
err = errors.InvalidShelfId(invalid_id)
628
628
self.assertEqual('"foo" is not a valid shelf id, '
629
'try a number instead.', str(err))
629
'try a number instead.', str(err))
631
631
def test_unresumable_write_group(self):
632
632
repo = "dummy repo"
736
736
def test_missing_format_string(self):
737
737
e = ErrorWithNoFormat(param='randomvalue')
738
738
self.assertStartsWith(str(e),
739
"Unprintable exception ErrorWithNoFormat")
739
"Unprintable exception ErrorWithNoFormat")
741
741
def test_mismatched_format_args(self):
742
742
# Even though ErrorWithBadFormat's format string does not match the
749
749
def test_cannot_bind_address(self):
750
750
# see <https://bugs.launchpad.net/bzr/+bug/286871>
751
751
e = errors.CannotBindAddress('example.com', 22,
752
socket.error(13, 'Permission denied'))
753
self.assertContainsRe(str(e),
752
socket.error(13, 'Permission denied'))
753
self.assertContainsRe(
754
755
r'Cannot bind address "example\.com:22":.*Permission denied')
756
def test_file_timestamp_unavailable(self):
757
def test_file_timestamp_unavailable(self):
757
758
e = errors.FileTimestampUnavailable("/path/foo")
758
self.assertEquals("The filestamp for /path/foo is not available.",
759
self.assertEqual("The filestamp for /path/foo is not available.",
761
762
def test_transform_rename_failed(self):
762
763
e = errors.TransformRenameFailed(u"from", u"to", "readonly file", 2)
764
765
u"Failed to rename from to to: readonly file",