~bzr-pqm/bzr/bzr.dev

1530.2.1 by Robert Collins
Start tests for api usage.
1
The Transport API in bzrlib provides URL based access to network resources.
2
3
   >>> import os
1711.7.23 by John Arbash Meinel
The api doc tests were using invalid paths on win32, fix them
4
   >>> import sys
1685.1.45 by John Arbash Meinel
Moved url functions into bzrlib.urlutils
5
   >>> from bzrlib.osutils import getcwd, dirname
6
   >>> from bzrlib.urlutils import local_path_from_url
1530.2.1 by Robert Collins
Start tests for api usage.
7
   >>> import bzrlib.transport as transport
1711.7.23 by John Arbash Meinel
The api doc tests were using invalid paths on win32, fix them
8
   >>> if sys.platform == 'win32':
6083.1.1 by Jelmer Vernooij
Use get_transport_from_{url,path} in more places.
9
   ...     root = transport.get_transport_from_url('file:///C:/')
1711.7.23 by John Arbash Meinel
The api doc tests were using invalid paths on win32, fix them
10
   ... else:
6083.1.1 by Jelmer Vernooij
Use get_transport_from_{url,path} in more places.
11
   ...     root = transport.get_transport_from_url('file:///')
1530.2.1 by Robert Collins
Start tests for api usage.
12
   >>>
13
14
Each Transport instance represents a single logical directory.
15
6083.1.1 by Jelmer Vernooij
Use get_transport_from_{url,path} in more places.
16
   >>> dir = transport.get_transport_from_path(".")
1685.1.32 by John Arbash Meinel
When unable to find an appropriate protocol, we now raise InvalidURL rather than always returning LocalTransport
17
   >>> local_path_from_url(dir.base) == getcwd() + '/'
1530.2.1 by Robert Collins
Start tests for api usage.
18
   True
19
20
You can change directories via the clone method:
21
22
   >>> parent = dir.clone('..')
1685.1.32 by John Arbash Meinel
When unable to find an appropriate protocol, we now raise InvalidURL rather than always returning LocalTransport
23
   >>> local_path_from_url(parent.base) == (dirname(getcwd()).rstrip('/') + '/')
1530.2.1 by Robert Collins
Start tests for api usage.
24
   True