~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/__init__.py

  • Committer: Martin Pool
  • Date: 2007-04-01 06:19:16 UTC
  • mfrom: (2323.5.20 0.15-integration)
  • mto: This revision was merged to the branch mainline in revision 2390.
  • Revision ID: mbp@sourcefrog.net-20070401061916-plpgsxdf8g7gll9o
Merge 0.15 final release back to trunk, including: recommend upgrades of old workingtrees, handle multiple http redirections, some dirstate fixes, 

Show diffs side-by-side

added added

removed removed

Lines of Context:
868
868
                excName = str(excClass)
869
869
            raise self.failureException, "%s not raised" % excName
870
870
 
 
871
    def assertRaises(self, excClass, func, *args, **kwargs):
 
872
        """Assert that a callable raises a particular exception.
 
873
 
 
874
        :param excClass: As for the except statement, this may be either an
 
875
        exception class, or a tuple of classes.
 
876
 
 
877
        Returns the exception so that you can examine it.
 
878
        """
 
879
        try:
 
880
            func(*args, **kwargs)
 
881
        except excClass, e:
 
882
            return e
 
883
        else:
 
884
            if getattr(excClass,'__name__', None) is not None:
 
885
                excName = excClass.__name__
 
886
            else:
 
887
                # probably a tuple
 
888
                excName = str(excClass)
 
889
            raise self.failureException, "%s not raised" % excName
 
890
 
871
891
    def assertIs(self, left, right, message=None):
872
892
        if not (left is right):
873
893
            if message is not None: