~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_transport.py

  • Committer: John Arbash Meinel
  • Date: 2007-07-13 02:23:34 UTC
  • mfrom: (2592 +trunk) (2612 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2614.
  • Revision ID: john@arbash-meinel.com-20070713022334-qb6ewgo6v4251yd9
[merge] bzr.dev 2612

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
                           NoSuchFile,
33
33
                           PathNotChild,
34
34
                           TransportNotPossible,
 
35
                           ConnectionError,
 
36
                           DependencyNotPresent,
 
37
                           ReadError,
35
38
                           UnsupportedProtocol,
36
39
                           )
37
40
from bzrlib.tests import TestCase, TestCaseInTempDir
40
43
                              _set_protocol_handlers,
41
44
                              _get_transport_modules,
42
45
                              get_transport,
 
46
                              LateReadError,
43
47
                              register_lazy_transport,
44
48
                              register_transport_proto,
45
49
                              _clear_protocol_handlers,
117
121
        finally:
118
122
            _set_protocol_handlers(saved_handlers)
119
123
 
 
124
    def test_LateReadError(self):
 
125
        """The LateReadError helper should raise on read()."""
 
126
        a_file = LateReadError('a path')
 
127
        try:
 
128
            a_file.read()
 
129
        except ReadError, error:
 
130
            self.assertEqual('a path', error.path)
 
131
        self.assertRaises(ReadError, a_file.read, 40)
 
132
        a_file.close()
 
133
 
120
134
    def test__combine_paths(self):
121
135
        t = Transport('/')
122
136
        self.assertEqual('/home/sarah/project/foo',
540
554
        self._server.setUp()
541
555
        self.addCleanup(self._server.tearDown)
542
556
 
543
 
    def get_transport(self):
544
 
        """Return a connected transport to the local directory."""
 
557
    def get_transport(self, relpath=None):
 
558
        """Return a connected transport to the local directory.
 
559
 
 
560
        :param relpath: a path relative to the base url.
 
561
        """
545
562
        base_url = self._server.get_url()
 
563
        url = self._adjust_url(base_url, relpath)
546
564
        # try getting the transport via the regular interface:
547
 
        t = get_transport(base_url)
 
565
        t = get_transport(url)
548
566
        if not isinstance(t, self.transport_class):
549
567
            # we did not get the correct transport class type. Override the
550
568
            # regular connection behaviour by direct construction.
551
 
            t = self.transport_class(base_url)
 
569
            t = self.transport_class(url)
552
570
        return t
553
571
 
554
572