~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/__init__.py

  • Committer: John Arbash Meinel
  • Date: 2006-08-17 13:53:36 UTC
  • mfrom: (1939 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1940.
  • Revision ID: john@arbash-meinel.com-20060817135336-100de82962355d3b
[merge] bzr.dev 1939

Show diffs side-by-side

added added

removed removed

Lines of Context:
65
65
from bzrlib.revision import common_ancestor
66
66
from bzrlib.revisionspec import RevisionSpec
67
67
import bzrlib.store
 
68
from bzrlib import symbol_versioning
68
69
import bzrlib.trace
69
70
from bzrlib.transport import get_transport
70
71
import bzrlib.transport
576
577
            self.fail("%r is an instance of %s rather than %s" % (
577
578
                obj, obj.__class__, kls))
578
579
 
 
580
    def assertDeprecated(self, expected, callable, *args, **kwargs):
 
581
        """Assert that a callable is deprecated in a particular way.
 
582
 
 
583
        :param expected: a list of the deprecation warnings expected, in order
 
584
        :param callable: The callable to call
 
585
        :param args: The positional arguments for the callable
 
586
        :param kwargs: The keyword arguments for the callable
 
587
        """
 
588
        local_warnings = []
 
589
        def capture_warnings(msg, cls, stacklevel=None):
 
590
            self.assertEqual(cls, DeprecationWarning)
 
591
            local_warnings.append(msg)
 
592
        method = symbol_versioning.warn
 
593
        symbol_versioning.set_warning_method(capture_warnings)
 
594
        try:
 
595
            callable(*args, **kwargs)
 
596
        finally:
 
597
            result = symbol_versioning.set_warning_method(method)
 
598
        self.assertEqual(expected, local_warnings)
 
599
        return result
 
600
 
579
601
    def _startLogFile(self):
580
602
        """Send bzr and test log messages to a temporary file.
581
603