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

  • Committer: John Arbash Meinel
  • Date: 2008-09-05 03:11:40 UTC
  • mfrom: (3691 +trunk)
  • mto: (3697.7.4 1.7)
  • mto: This revision was merged to the branch mainline in revision 3748.
  • Revision ID: john@arbash-meinel.com-20080905031140-hj0adlcf30l7i99v
Merge in bzr.dev 3691

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
19
19
"""Tests for the formatting and construction of errors."""
20
20
 
 
21
import sys
21
22
from bzrlib import (
22
23
    bzrdir,
23
24
    errors,
44
45
            "Error: the reason why",
45
46
            str(error))
46
47
 
 
48
    def test_dirstate_corrupt(self):
 
49
        error = errors.DirstateCorrupt('.bzr/checkout/dirstate',
 
50
                                       'trailing garbage: "x"')
 
51
        self.assertEqualDiff("The dirstate file (.bzr/checkout/dirstate)"
 
52
            " appears to be corrupt: trailing garbage: \"x\"",
 
53
            str(error))
 
54
 
47
55
    def test_disabled_method(self):
48
56
        error = errors.DisabledMethod("class name")
49
57
        self.assertEqualDiff(
383
391
            host='ahost', port=444, msg='Unable to connect to ssh host',
384
392
            orig_error='my_error')
385
393
 
 
394
    def test_target_not_branch(self):
 
395
        """Test the formatting of TargetNotBranch."""
 
396
        error = errors.TargetNotBranch('foo')
 
397
        self.assertEqual(
 
398
            "Your branch does not have all of the revisions required in "
 
399
            "order to merge this merge directive and the target "
 
400
            "location specified in the merge directive is not a branch: "
 
401
            "foo.", str(error))
 
402
 
386
403
    def test_malformed_bug_identifier(self):
387
404
        """Test the formatting of MalformedBugIdentifier."""
388
405
        error = errors.MalformedBugIdentifier('bogus', 'reason for bogosity')
510
527
        err = errors.UnknownRules(['foo', 'bar'])
511
528
        self.assertEquals("Unknown rules detected: foo, bar.", str(err))
512
529
 
 
530
    def test_hook_failed(self):
 
531
        # Create an exc_info tuple by raising and catching an exception.
 
532
        try:
 
533
            1/0
 
534
        except ZeroDivisionError:
 
535
            exc_info = sys.exc_info()
 
536
        err = errors.HookFailed('hook stage', 'hook name', exc_info)
 
537
        self.assertStartsWith(
 
538
            str(err), 'Hook \'hook name\' during hook stage failed:\n')
 
539
        self.assertEndsWith(
 
540
            str(err), 'integer division or modulo by zero')
 
541
 
 
542
    def test_tip_change_rejected(self):
 
543
        err = errors.TipChangeRejected(u'Unicode message\N{INTERROBANG}')
 
544
        self.assertEquals(
 
545
            u'Tip change rejected: Unicode message\N{INTERROBANG}',
 
546
            unicode(err))
 
547
        self.assertEquals(
 
548
            'Tip change rejected: Unicode message\xe2\x80\xbd',
 
549
            str(err))
 
550
 
513
551
 
514
552
class PassThroughError(errors.BzrError):
515
553