~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_errors.py

  • Committer: John Arbash Meinel
  • Date: 2008-08-14 17:08:56 UTC
  • mfrom: (3629 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3633.
  • Revision ID: john@arbash-meinel.com-20080814170856-p2ie5z7l6vowrftz
merge bzr.dev 3629, update NEWS entry to be in correct location.

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,
383
384
            host='ahost', port=444, msg='Unable to connect to ssh host',
384
385
            orig_error='my_error')
385
386
 
 
387
    def test_target_not_branch(self):
 
388
        """Test the formatting of TargetNotBranch."""
 
389
        error = errors.TargetNotBranch('foo')
 
390
        self.assertEqual(
 
391
            "Your branch does not have all of the revisions required in "
 
392
            "order to merge this merge directive and the target "
 
393
            "location specified in the merge directive is not a branch: "
 
394
            "foo.", str(error))
 
395
 
386
396
    def test_malformed_bug_identifier(self):
387
397
        """Test the formatting of MalformedBugIdentifier."""
388
398
        error = errors.MalformedBugIdentifier('bogus', 'reason for bogosity')
510
520
        err = errors.UnknownRules(['foo', 'bar'])
511
521
        self.assertEquals("Unknown rules detected: foo, bar.", str(err))
512
522
 
 
523
    def test_hook_failed(self):
 
524
        # Create an exc_info tuple by raising and catching an exception.
 
525
        try:
 
526
            1/0
 
527
        except ZeroDivisionError:
 
528
            exc_info = sys.exc_info()
 
529
        err = errors.HookFailed('hook stage', 'hook name', exc_info)
 
530
        self.assertStartsWith(
 
531
            str(err), 'Hook \'hook name\' during hook stage failed:\n')
 
532
        self.assertEndsWith(
 
533
            str(err), 'integer division or modulo by zero')
 
534
 
 
535
    def test_tip_change_rejected(self):
 
536
        err = errors.TipChangeRejected(u'Unicode message\N{INTERROBANG}')
 
537
        self.assertEquals(
 
538
            u'Tip change rejected: Unicode message\N{INTERROBANG}',
 
539
            unicode(err))
 
540
        self.assertEquals(
 
541
            'Tip change rejected: Unicode message\xe2\x80\xbd',
 
542
            str(err))
 
543
 
513
544
 
514
545
class PassThroughError(errors.BzrError):
515
546