~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_urlutils.py

  • Committer: Vincent Ladeuil
  • Date: 2010-06-17 09:23:19 UTC
  • mfrom: (5301 +trunk)
  • mto: (5247.1.8 first-try)
  • mto: This revision was merged to the branch mainline in revision 5326.
  • Revision ID: v.ladeuil+lp@free.fr-20100617092319-da2bzdtf3j0voynf
Merge bzr.dev into cleanup

Show diffs side-by-side

added added

removed removed

Lines of Context:
156
156
        # Weird stuff
157
157
        # Can't have slashes or colons in the scheme
158
158
        test_one('/path/to/://foo', None)
159
 
        test_one('path:path://foo', None)
 
159
        test_one('scheme:stuff://foo', ('scheme', 'stuff://foo'))
160
160
        # Must have more than one character for scheme
161
161
        test_one('C://foo', None)
162
162
        test_one('ab://foo', ('ab', 'foo'))
195
195
            dirname('path/to/foo/', exclude_trailing_slash=False))
196
196
        self.assertEqual('path/..', dirname('path/../foo'))
197
197
        self.assertEqual('../path', dirname('../path/foo'))
 
198
    
 
199
    def test_is_url(self):
 
200
        self.assertTrue(urlutils.is_url('http://foo/bar'))
 
201
        self.assertTrue(urlutils.is_url('bzr+ssh://foo/bar'))
 
202
        self.assertTrue(urlutils.is_url('lp:foo/bar'))
 
203
        self.assertTrue(urlutils.is_url('file:///foo/bar'))
 
204
        self.assertFalse(urlutils.is_url(''))
 
205
        self.assertFalse(urlutils.is_url('foo'))
 
206
        self.assertFalse(urlutils.is_url('foo/bar'))
 
207
        self.assertFalse(urlutils.is_url('/foo'))
 
208
        self.assertFalse(urlutils.is_url('/foo/bar'))
 
209
        self.assertFalse(urlutils.is_url('C:/'))
 
210
        self.assertFalse(urlutils.is_url('C:/foo'))
 
211
        self.assertFalse(urlutils.is_url('C:/foo/bar'))
198
212
 
199
213
    def test_join(self):
200
214
        def test(expected, *args):
210
224
        test('http://foo/bar/baz', 'http://foo', 'bar/baz')
211
225
        test('http://foo/baz', 'http://foo', 'bar/../baz')
212
226
        test('http://foo/baz', 'http://foo/bar/', '../baz')
 
227
        test('lp:foo/bar', 'lp:foo', 'bar')
 
228
        test('lp:foo/bar/baz', 'lp:foo', 'bar/baz')
213
229
 
214
230
        # Absolute paths
215
231
        test('http://foo', 'http://foo') # abs url with nothing is preserved.
219
235
        test('http://bar/', 'http://foo', 'http://bar/')
220
236
        test('http://bar/a', 'http://foo', 'http://bar/a')
221
237
        test('http://bar/a/', 'http://foo', 'http://bar/a/')
 
238
        test('lp:bar', 'http://foo', 'lp:bar')
 
239
        test('lp:bar', 'lp:foo', 'lp:bar')
 
240
        test('file:///stuff', 'lp:foo', 'file:///stuff')
222
241
 
223
242
        # From a base path
224
243
        test('file:///foo', 'file:///', 'foo')