~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_urlutils.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2011-08-12 18:48:36 UTC
  • mfrom: (6055.2.19 unparsedurl-b)
  • Revision ID: pqm@pqm.ubuntu.com-20110812184836-5jv1u3ns0s74zsg0
(jelmer) Add URL.clone,
 URL.__str__ and use them in various places. (Jelmer Vernooij)

Show diffs side-by-side

added added

removed removed

Lines of Context:
864
864
            "<URL('http', None, None, '1:2:3::40', 80, '/one')>",
865
865
            repr(parsed))
866
866
 
 
867
    def test_str(self):
 
868
        parsed = urlutils.URL.from_string('http://[1:2:3::40]:80/one')
 
869
        self.assertEquals('http://[1:2:3::40]:80/one', str(parsed))
 
870
 
 
871
    def test__combine_paths(self):
 
872
        combine = urlutils.URL._combine_paths
 
873
        self.assertEqual('/home/sarah/project/foo',
 
874
                         combine('/home/sarah', 'project/foo'))
 
875
        self.assertEqual('/etc',
 
876
                         combine('/home/sarah', '../../etc'))
 
877
        self.assertEqual('/etc',
 
878
                         combine('/home/sarah', '../../../etc'))
 
879
        self.assertEqual('/etc',
 
880
                         combine('/home/sarah', '/etc'))
 
881
 
 
882
    def test_clone(self):
 
883
        url = urlutils.URL.from_string('http://[1:2:3::40]:80/one')
 
884
        url1 = url.clone("two")
 
885
        self.assertEquals("/one/two", url1.path)
 
886
        url2 = url.clone("/two")
 
887
        self.assertEquals("/two", url2.path)
 
888
        url3 = url.clone()
 
889
        self.assertIsNot(url, url3)
 
890
        self.assertEquals(url, url3)