~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_trace.py

  • Committer: Vincent Ladeuil
  • Date: 2007-07-22 15:44:59 UTC
  • mto: This revision was merged to the branch mainline in revision 2646.
  • Revision ID: v.ladeuil+lp@free.fr-20070722154459-520ws2gnifghkpgy
From review comments, use a private scheme for testing.

* bzrlib/transport/__init__.py:
(_unregister_urlparse_netloc_protocol): New function.

* bzrlib/tests/transport_util.py:
(InstrumentedTransport.__init__): Use a dedicated scheme.
(TestCaseWithConnectionHookedTransport.setUp): Reworked to
register the new transport.
(TestCaseWithConnectionHookedTransport.get_url): Use our dedicated
scheme.
(TestCaseWithConnectionHookedTransport.install_hooks,
TestCaseWithConnectionHookedTransport.reset_hooks): Registering
transport is setUp job.

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
    errors,
28
28
    )
29
29
from bzrlib.tests import TestCaseInTempDir, TestCase
30
 
from bzrlib.trace import mutter, mutter_callsite, report_exception
 
30
from bzrlib.trace import mutter, report_exception
31
31
 
32
32
 
33
33
def _format_exception():
83
83
            pass
84
84
        msg = _format_exception()
85
85
        self.assertTrue(len(msg) > 0)
86
 
        self.assertEqualDiff(msg, 'bzr: ERROR: Not a branch: \"wibble\".\n')
 
86
        self.assertEqualDiff(msg, 'bzr: ERROR: Not a branch: wibble\n')
87
87
 
88
88
    def test_trace_unicode(self):
89
89
        """Write Unicode to trace log"""
113
113
        else:
114
114
            self.fail("expected error not raised")
115
115
 
116
 
    def test_mutter_callsite_1(self):
117
 
        """mutter_callsite can capture 1 level of stack frame."""
118
 
        mutter_callsite(1, "foo %s", "a string")
119
 
        log = self._get_log(keep_log_file=True)
120
 
        # begin with the message
121
 
        self.assertStartsWith(log, 'foo a string\nCalled from:\n')
122
 
        # should show two frame: this frame and the one above
123
 
        self.assertContainsRe(log,
124
 
            'test_trace\.py", line \d+, in test_mutter_callsite_1\n')
125
 
        # this frame should be the final one
126
 
        self.assertEndsWith(log, ' "a string")\n')
127
 
 
128
 
    def test_mutter_callsite_2(self):
129
 
        """mutter_callsite can capture 2 levels of stack frame."""
130
 
        mutter_callsite(2, "foo %s", "a string")
131
 
        log = self._get_log(keep_log_file=True)
132
 
        # begin with the message
133
 
        self.assertStartsWith(log, 'foo a string\nCalled from:\n')
134
 
        # should show two frame: this frame and the one above
135
 
        self.assertContainsRe(log,
136
 
            'test_trace.py", line \d+, in test_mutter_callsite_2\n')
137
 
        # this frame should be the final one
138
 
        self.assertEndsWith(log, ' "a string")\n')
139
 
 
140
116
    def test_mutter_never_fails(self):
141
117
        # Even if the decode/encode stage fails, mutter should not
142
118
        # raise an exception
147
123
        self.assertContainsRe(log, 'Writing a greek mu')
148
124
        self.assertContainsRe(log, "But fails in an ascii string")
149
125
        self.assertContainsRe(log, u"ascii argument: \xb5")
150