Rev 2521: Fix 110448 by adding a relpath parameter to get_transport. in file:///v/home/vila/src/bugs/110448/
Vincent Ladeuil
v.ladeuil+lp at free.fr
Sat Jun 9 16:34:11 BST 2007
At file:///v/home/vila/src/bugs/110448/
------------------------------------------------------------
revno: 2521
revision-id: v.ladeuil+lp at free.fr-20070609153407-c5jx52cfk47jydq5
parent: pqm at pqm.ubuntu.com-20070608134340-flu6dlpzyo7izrrs
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: 110448
timestamp: Sat 2007-06-09 17:34:07 +0200
message:
Fix 110448 by adding a relpath parameter to get_transport.
* bzrlib/tests/__init__.py:
(TestCaseWithMemoryTransport.get_transport,
get_readonly_transport): Add a relpath parameter.
* bzrlib/tests/test_transport.py:
(TestTransportImplementation.get_transport): Add a relpath
parameter.
* bzrlib/tests/test_sftp_transport.py:
(TestCaseWithSFTPServer.get_tranport): Deleted.
* bzrlib/tests/test_dirstate.py:
(TestCaseWithDirState.create_basic_dirstate): Use the new shiny
get_transport !
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/tests/__init__.py selftest.py-20050531073622-8d0e3c8845c97a64
bzrlib/tests/test_dirstate.py test_dirstate.py-20060728012006-d6mvoihjb3je9peu-2
bzrlib/tests/test_sftp_transport.py testsftp.py-20051027032739-247570325fec7e7e
bzrlib/tests/test_transport.py testtransport.py-20050718175618-e5cdb99f4555ddce
-------------- next part --------------
=== modified file 'NEWS'
--- a/NEWS 2007-06-07 22:31:44 +0000
+++ b/NEWS 2007-06-09 15:34:07 +0000
@@ -88,6 +88,10 @@
* Tests no longer fail when BZR_REMOTE_PATH is set in the environment.
(Daniel Watkins, #111958)
+ * Add a relpath parameter to get_transport methods in test framework to
+ avoid useless cloning.
+ (Vincent Ladeuil, #110448)
+
bzr 0.16 2007-05-07
BUGFIXES:
=== modified file 'bzrlib/tests/__init__.py'
--- a/bzrlib/tests/__init__.py 2007-06-06 23:16:55 +0000
+++ b/bzrlib/tests/__init__.py 2007-06-09 15:34:07 +0000
@@ -1617,19 +1617,27 @@
self.transport_readonly_server = None
self.__vfs_server = None
- def get_transport(self):
- """Return a writeable transport for the test scratch space"""
- t = get_transport(self.get_url())
+ def get_transport(self, relpath=None):
+ """Return a writeable transport.
+
+ This transport is for the test scratch space relative to
+ "self._test_root""
+
+ :param relpath: a path relative to the base url.
+ """
+ t = get_transport(self.get_url(relpath))
self.assertFalse(t.is_readonly())
return t
- def get_readonly_transport(self):
+ def get_readonly_transport(self, relpath=None):
"""Return a readonly transport for the test scratch space
This can be used to test that operations which should only need
readonly access in fact do not try to write.
+
+ :param relpath: a path relative to the base url.
"""
- t = get_transport(self.get_readonly_url())
+ t = get_transport(self.get_readonly_url(relpath))
self.assertTrue(t.is_readonly())
return t
@@ -1666,11 +1674,7 @@
These should only be downwards relative, not upwards.
"""
base = self.get_readonly_server().get_url()
- if relpath is not None:
- if not base.endswith('/'):
- base = base + '/'
- base = base + relpath
- return base
+ return self._adjust_url(base, relpath)
def get_vfs_only_server(self):
"""Get the vfs only read/write server instance.
=== modified file 'bzrlib/tests/test_dirstate.py'
--- a/bzrlib/tests/test_dirstate.py 2007-06-07 22:31:44 +0000
+++ b/bzrlib/tests/test_dirstate.py 2007-06-09 15:34:07 +0000
@@ -200,7 +200,7 @@
tree.commit('initial', rev_id='rev-1')
revision_id = 'rev-1'
# a_packed_stat = dirstate.pack_stat(os.stat('tree/a'))
- t = self.get_transport().clone('tree')
+ t = self.get_transport('tree')
a_text = t.get_bytes('a')
a_sha = osutils.sha_string(a_text)
a_len = len(a_text)
=== modified file 'bzrlib/tests/test_sftp_transport.py'
--- a/bzrlib/tests/test_sftp_transport.py 2007-03-28 08:49:06 +0000
+++ b/bzrlib/tests/test_sftp_transport.py 2007-06-09 15:34:07 +0000
@@ -59,10 +59,6 @@
raise TestSkipped('you must have paramiko to run this test')
set_test_transport_to_sftp(self)
- def get_transport(self, path=None):
- """Return a transport relative to self._test_root."""
- return bzrlib.transport.get_transport(self.get_url(path))
-
class SFTPLockTests (TestCaseWithSFTPServer):
=== modified file 'bzrlib/tests/test_transport.py'
--- a/bzrlib/tests/test_transport.py 2007-05-04 10:41:31 +0000
+++ b/bzrlib/tests/test_transport.py 2007-06-09 15:34:07 +0000
@@ -540,15 +540,19 @@
self._server.setUp()
self.addCleanup(self._server.tearDown)
- def get_transport(self):
- """Return a connected transport to the local directory."""
+ def get_transport(self, relpath=None):
+ """Return a connected transport to the local directory.
+
+ :param relpath: a path relative to the base url.
+ """
base_url = self._server.get_url()
+ url = self._adjust_url(base_url, relpath)
# try getting the transport via the regular interface:
- t = get_transport(base_url)
+ t = get_transport(url)
if not isinstance(t, self.transport_class):
# we did not get the correct transport class type. Override the
# regular connection behaviour by direct construction.
- t = self.transport_class(base_url)
+ t = self.transport_class(url)
return t
More information about the bazaar-commits
mailing list