~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/__init__.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-07-22 09:03:35 UTC
  • mfrom: (4449.3.47 387717-progress-bar-tty)
  • Revision ID: pqm@pqm.ubuntu.com-20090722090335-m1okio1ev9bwytui
(mbp) various UIFactory cleanups including bug 387717

Show diffs side-by-side

added added

removed removed

Lines of Context:
102
102
                          TestLoader,
103
103
                          )
104
104
from bzrlib.tests.treeshape import build_tree_contents
 
105
from bzrlib.ui.text import TextUIFactory
105
106
import bzrlib.version_info_formats.format_custom
106
107
from bzrlib.workingtree import WorkingTree, WorkingTreeFormat2
107
108
 
702
703
            return setattr(self._cstring, name, val)
703
704
 
704
705
 
705
 
class TestUIFactory(ui.CLIUIFactory):
 
706
class TestUIFactory(TextUIFactory):
706
707
    """A UI Factory for testing.
707
708
 
708
709
    Hide the progress bar but emit note()s.
1093
1094
                         osutils.realpath(path2),
1094
1095
                         "apparent paths:\na = %s\nb = %s\n," % (path1, path2))
1095
1096
 
1096
 
    def assertIsInstance(self, obj, kls):
1097
 
        """Fail if obj is not an instance of kls"""
 
1097
    def assertIsInstance(self, obj, kls, msg=None):
 
1098
        """Fail if obj is not an instance of kls
 
1099
        
 
1100
        :param msg: Supplementary message to show if the assertion fails.
 
1101
        """
1098
1102
        if not isinstance(obj, kls):
1099
 
            self.fail("%r is an instance of %s rather than %s" % (
1100
 
                obj, obj.__class__, kls))
 
1103
            m = "%r is an instance of %s rather than %s" % (
 
1104
                obj, obj.__class__, kls)
 
1105
            if msg:
 
1106
                m += ": " + msg
 
1107
            self.fail(m)
1101
1108
 
1102
1109
    def expectFailure(self, reason, assertion, *args, **kwargs):
1103
1110
        """Invoke a test, expecting it to fail for the given reason.
1325
1332
            'BZR_PROGRESS_BAR': None,
1326
1333
            'BZR_LOG': None,
1327
1334
            'BZR_PLUGIN_PATH': None,
 
1335
            # Make sure that any text ui tests are consistent regardless of
 
1336
            # the environment the test case is run in; you may want tests that
 
1337
            # test other combinations.  'dumb' is a reasonable guess for tests
 
1338
            # going to a pipe or a StringIO.
 
1339
            'TERM': 'dumb',
 
1340
            'LINES': '25',
 
1341
            'COLUMNS': '80',
1328
1342
            # SSH Agent
1329
1343
            'SSH_AUTH_SOCK': None,
1330
1344
            # Proxies