~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: 2011-01-12 21:27:00 UTC
  • mto: This revision was merged to the branch mainline in revision 5605.
  • Revision ID: john@arbash-meinel.com-20110112212700-esqmtrmevddxrsq2
Clean up the test slightly, hoping to avoid race conditions, update NEWS

Show diffs side-by-side

added added

removed removed

Lines of Context:
300
300
            str(error))
301
301
 
302
302
    def test_up_to_date(self):
303
 
        error = errors.UpToDateFormat("someformat")
304
 
        self.assertEqualDiff(
305
 
            "The branch format someformat is already at the most "
306
 
            "recent format.", str(error))
 
303
        error = errors.UpToDateFormat(bzrdir.BzrDirFormat4())
 
304
        self.assertEqualDiff("The branch format All-in-one "
 
305
                             "format 4 is already at the most "
 
306
                             "recent format.",
 
307
                             str(error))
307
308
 
308
309
    def test_corrupt_repository(self):
309
310
        repo = self.make_repository('.')
577
578
        try:
578
579
            1/0
579
580
        except ZeroDivisionError:
580
 
            err = errors.HookFailed('hook stage', 'hook name', sys.exc_info(),
581
 
                warn=False)
582
 
        # GZ 2010-11-08: Should not store exc_info in exception instances, but
583
 
        #                HookFailed is deprecated anyway and could maybe go.
584
 
        try:
585
 
            self.assertStartsWith(
586
 
                str(err), 'Hook \'hook name\' during hook stage failed:\n')
587
 
            self.assertEndsWith(
588
 
                str(err), 'integer division or modulo by zero')
589
 
        finally:
590
 
            del err
 
581
            exc_info = sys.exc_info()
 
582
        err = errors.HookFailed('hook stage', 'hook name', exc_info, warn=False)
 
583
        self.assertStartsWith(
 
584
            str(err), 'Hook \'hook name\' during hook stage failed:\n')
 
585
        self.assertEndsWith(
 
586
            str(err), 'integer division or modulo by zero')
591
587
 
592
588
    def test_tip_change_rejected(self):
593
589
        err = errors.TipChangeRejected(u'Unicode message\N{INTERROBANG}')
616
612
        try:
617
613
            raise Exception("example error")
618
614
        except Exception:
619
 
            err = errors.SmartMessageHandlerError(sys.exc_info())
620
 
        # GZ 2010-11-08: Should not store exc_info in exception instances.
621
 
        try:
622
 
            self.assertStartsWith(
623
 
                str(err), "The message handler raised an exception:\n")
624
 
            self.assertEndsWith(str(err), "Exception: example error\n")
625
 
        finally:
626
 
            del err
 
615
            exc_info = sys.exc_info()
 
616
        err = errors.SmartMessageHandlerError(exc_info)
 
617
        self.assertStartsWith(
 
618
            str(err), "The message handler raised an exception:\n")
 
619
        self.assertEndsWith(str(err), "Exception: example error\n")
627
620
 
628
621
    def test_must_have_working_tree(self):
629
622
        err = errors.MustHaveWorkingTree('foo', 'bar')