~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_read_bundle.py

  • Committer: Robert Collins
  • Date: 2006-07-20 05:04:08 UTC
  • mto: (1874.1.1 bzr.socket-delay)
  • mto: This revision was merged to the branch mainline in revision 1873.
  • Revision ID: robertc@robertcollins.net-20060720050408-8a40f60b685f140b
Reduce code duplication in transport-parameterised tests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
import bzrlib.bzrdir
25
25
import bzrlib.errors as errors
26
26
from bzrlib.tests import TestCaseInTempDir
 
27
from bzrlib.tests.test_transport import TestTransportImplementation
27
28
import bzrlib.transport
28
29
from bzrlib.transport.memory import MemoryTransport
29
30
import bzrlib.urlutils
30
31
 
31
32
 
32
 
# jam 20060615 Originally I thought I should use TestCaseWithTransport
33
 
#       but it turns out that doesn't play well with the transport adapter
34
 
class TestReadBundleFromURL(TestCaseInTempDir):
 
33
class TestReadBundleFromURL(TestTransportImplementation):
35
34
    """Test that read_bundle works properly across multiple transports"""
36
35
 
37
 
    def setUp(self):
38
 
        super(TestReadBundleFromURL, self).setUp()
39
 
        self._server = self.transport_server()
40
 
        self._server.setUp()
41
 
        self._transport = None
42
 
 
43
 
    def tearDown(self):
44
 
        self._transport = None
45
 
        self._server.tearDown()
46
 
        super(TestReadBundleFromURL, self).tearDown()
47
 
        
48
 
    def get_transport(self):
49
 
        """Return a connected transport to the local directory."""
50
 
        base_url = self._server.get_url()
51
 
        t = bzrlib.transport.get_transport(base_url)
52
 
        if not isinstance(t, self.transport_class):
53
 
            # we want to make sure to construct one particular class, even if
54
 
            # there are several available implementations of this transport;
55
 
            # therefore construct it by hand rather than through the regular
56
 
            # get_transport method
57
 
            t = self.transport_class(base_url)
58
 
        return t
59
 
 
60
36
    def get_url(self, relpath=''):
61
37
        return bzrlib.urlutils.join(self._server.get_url(), relpath)
62
38