/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/__init__.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-03-03 08:54:13 UTC
  • mfrom: (4070.2.8 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20090303085413-35seprvnu885xorz
(robertc) Create new server verb BzrDir.cloning_metadir and alter
        Branch.sprout to prevent race conditions during stacked
        branching. (Robert Collins, Andrew Bennetts)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1820
1820
        return sio
1821
1821
 
1822
1822
 
 
1823
class CapturedCall(object):
 
1824
    """A helper for capturing smart server calls for easy debug analysis."""
 
1825
 
 
1826
    def __init__(self, params, prefix_length):
 
1827
        """Capture the call with params and skip prefix_length stack frames."""
 
1828
        self.call = params
 
1829
        import traceback
 
1830
        # The last 5 frames are the __init__, the hook frame, and 3 smart
 
1831
        # client frames. Beyond this we could get more clever, but this is good
 
1832
        # enough for now.
 
1833
        stack = traceback.extract_stack()[prefix_length:-5]
 
1834
        self.stack = ''.join(traceback.format_list(stack))
 
1835
 
 
1836
    def __str__(self):
 
1837
        return self.call.method
 
1838
 
 
1839
    def __repr__(self):
 
1840
        return self.call.method
 
1841
 
 
1842
    def stack(self):
 
1843
        return self.stack
 
1844
 
 
1845
 
1823
1846
class TestCaseWithMemoryTransport(TestCase):
1824
1847
    """Common test class for tests that do not need disk resources.
1825
1848
 
2116
2139
        """Sets up a smart server as the transport server with a call log."""
2117
2140
        self.transport_server = server.SmartTCPServer_for_testing
2118
2141
        self.hpss_calls = []
 
2142
        import traceback
 
2143
        # Skip the current stack down to the caller of
 
2144
        # setup_smart_server_with_call_log
 
2145
        prefix_length = len(traceback.extract_stack()) - 2
2119
2146
        def capture_hpss_call(params):
2120
 
            import traceback
2121
 
            self.hpss_calls.append((params, traceback.format_stack()))
 
2147
            self.hpss_calls.append(
 
2148
                CapturedCall(params, prefix_length))
2122
2149
        client._SmartClient.hooks.install_named_hook(
2123
2150
            'call', capture_hpss_call, None)
2124
2151