~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/readonly.py

Add TestCaseWithTransport class that provides tests with read and write transport pairs.

Show diffs side-by-side

added added

removed removed

Lines of Context:
108
108
class ReadonlyServer(Server):
109
109
    """Server for the ReadonlyTransportDecorator for testing with."""
110
110
 
111
 
    def setUp(self):
112
 
        """See bzrlib.transport.Server.setUp."""
113
 
        from bzrlib.transport.local import LocalRelpathServer
114
 
        self._server = LocalRelpathServer()
115
 
        self._server.setUp()
 
111
    def setUp(self, server=None):
 
112
        """See bzrlib.transport.Server.setUp.
 
113
 
 
114
        :server: decorate the urls given by server. If not provided a
 
115
        LocalServer is created.
 
116
        """
 
117
        if server is not None:
 
118
            self._made_server = False
 
119
            self._server = server
 
120
        else:
 
121
            from bzrlib.transport.local import LocalRelpathServer
 
122
            self._made_server = True
 
123
            self._server = LocalRelpathServer()
 
124
            self._server.setUp()
116
125
 
117
126
    def tearDown(self):
118
127
        """See bzrlib.transport.Server.tearDown."""
119
 
        self._server.tearDown()
 
128
        if self._made_server:
 
129
            self._server.tearDown()
120
130
 
121
131
    def get_bogus_url(self):
122
132
        """See bzrlib.transport.Server.get_bogus_url."""