~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/__init__.py

Better (but still incomplete) design for bogus servers.

* bzrlib/transport/http/_urllib2_wrappers.py:
(AbstractHTTPHandler): Add 'Accept: */*' again to default headers
until I fully understand why and when it's needed or not (curl add
it if no Accept header is present).

* bzrlib/transport/http/_pycurl.py:
(PyCurlTransport._curl_perform): CURLE_GOT_NOTHING may be
considered as a ConnectionError, inspection of curl code reveals
that the case is sufficiently rare and low level related to not be
considered an http error per se.

* bzrlib/transport/http/__init__.py:
(WallHttpServer): Deleted.

* bzrlib/tests/test_http.py:
(TestBogusServer): Factor out the tests common to the bogus
servers.

* bzrlib/tests/__init__.py:
(TestCaseWithTransport.create_transport_server,
TestCaseWithTransport.create_transport_readonly_server): New
methods, allows test cases to specify the transport servers
without defining useless classes.
(TestCaseWithTransport.get_readonly_server): Use
create_transport_readonly_server.
(TestCaseWithTransport.get_server): Use create_transport_server.

* bzrlib/tests/HTTPTestUtil.py:
(TestCaseWithWebserver): Fix typo in doc string.
(TestCaseWithWallserver): Deleted.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1245
1245
        self.transport_server = default_transport
1246
1246
        self.transport_readonly_server = None
1247
1247
 
 
1248
    def create_transport_server(self):
 
1249
        """Create a transport server from class defined at init.
 
1250
 
 
1251
        This is mostly a hook for daugter classes.
 
1252
        """
 
1253
        return self.transport_server()
 
1254
 
 
1255
    def create_transport_readonly_server(self):
 
1256
        """Create a transport read-only server from class defined at init.
 
1257
 
 
1258
        This is mostly a hook for daugter classes.
 
1259
        """
 
1260
        return self.transport_readonly_server()
 
1261
 
1248
1262
    def get_readonly_url(self, relpath=None):
1249
1263
        """Get a URL for the readonly transport.
1250
1264
 
1273
1287
                self.__readonly_server = ReadonlyServer()
1274
1288
                self.__readonly_server.setUp(self.__server)
1275
1289
            else:
1276
 
                self.__readonly_server = self.transport_readonly_server()
 
1290
                self.__readonly_server = self.create_transport_readonly_server()
1277
1291
                self.__readonly_server.setUp()
1278
1292
            self.addCleanup(self.__readonly_server.tearDown)
1279
1293
        return self.__readonly_server
1285
1299
        diagnostics.
1286
1300
        """
1287
1301
        if self.__server is None:
1288
 
            self.__server = self.transport_server()
 
1302
            self.__server = self.create_transport_server()
1289
1303
            self.__server.setUp()
1290
1304
            self.addCleanup(self.__server.tearDown)
1291
1305
        return self.__server