~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_urlutils.py

  • Committer: John Arbash Meinel
  • Date: 2006-05-02 21:17:38 UTC
  • mto: This revision was merged to the branch mainline in revision 1752.
  • Revision ID: john@arbash-meinel.com-20060502211738-be512e6ec1e6e6cf
Updated strip_trailing_slash to support lots more url stuff, added tests

Show diffs side-by-side

added added

removed removed

Lines of Context:
73
73
        # Not a valid _win32 url, no drive letter
74
74
        self.assertRaises(InvalidURL, from_url, 'file:///path/to/foo')
75
75
 
 
76
    def test_strip_trailing_slash(self):
 
77
        sts = urlutils.strip_trailing_slash
 
78
        if sys.platform == 'win32':
 
79
            self.assertEqual('file:///C|/', sts('file:///C|/'))
 
80
            self.assertEqual('file:///C|/foo', sts('file:///C|/foo'))
 
81
            self.assertEqual('file:///C|/foo', sts('file:///C|/foo/'))
 
82
        else:
 
83
            self.assertEqual('file:///', sts('file:///'))
 
84
            self.assertEqual('file:///foo', sts('file:///foo'))
 
85
            self.assertEqual('file:///foo', sts('file:///foo/'))
 
86
 
 
87
        self.assertEqual('http://host/', sts('http://host/'))
 
88
        self.assertEqual('http://host/foo', sts('http://host/foo'))
 
89
        self.assertEqual('http://host/foo', sts('http://host/foo/'))
 
90
 
 
91
        # No need to fail just because the slash is missing
 
92
        self.assertEqual('http://host', sts('http://host'))
 
93
        # TODO: jam 20060502 Should this raise InvalidURL?
 
94
        self.assertEqual('file://', sts('file://'))
 
95
 
 
96
        self.assertEqual('random+scheme://user:pass@ahost:port/path',
 
97
            sts('random+scheme://user:pass@ahost:port/path'))
 
98
        self.assertEqual('random+scheme://user:pass@ahost:port/path',
 
99
            sts('random+scheme://user:pass@ahost:port/path/'))
 
100
        self.assertEqual('random+scheme://user:pass@ahost:port/',
 
101
            sts('random+scheme://user:pass@ahost:port/'))
 
102
 
 
103
        # Make sure relative paths work too
 
104
        self.assertEqual('path/to/foo', sts('path/to/foo'))
 
105
        self.assertEqual('path/to/foo', sts('path/to/foo/'))
 
106
        self.assertEqual('../to/foo', sts('../to/foo/'))
 
107
        self.assertEqual('path/../foo', sts('path/../foo/'))
 
108
 
76
109
    def test_unescape_for_display(self):
77
110
        # Test that URLs are converted to nice unicode strings for display
78
111
        disp = urlutils.unescape_for_display