/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_urlutils.py

  • Committer: John Arbash Meinel
  • Date: 2006-05-10 18:39:30 UTC
  • mto: This revision was merged to the branch mainline in revision 1752.
  • Revision ID: john@arbash-meinel.com-20060510183930-1dbe0bc58695ee47
Added an re for handling scheme paths.

Show diffs side-by-side

added added

removed removed

Lines of Context:
60
60
        self.assertEqual('foo', basename('path/../foo'))
61
61
        self.assertEqual('foo', basename('../path/foo'))
62
62
 
 
63
    def test_normalize_url(self):
 
64
        pass
 
65
 
 
66
    def test_url_scheme_re(self):
 
67
        # Test paths that may be URLs
 
68
        def test_one(url, scheme_and_path):
 
69
            """Assert that _url_scheme_re correctly matches
 
70
 
 
71
            :param scheme_and_path: The (scheme, path) that should be matched
 
72
                can be None, to indicate it should not match
 
73
            """
 
74
            m = urlutils._url_scheme_re.match(url)
 
75
            if scheme_and_path is None:
 
76
                self.assertEqual(None, m)
 
77
            else:
 
78
                self.assertEqual(scheme_and_path[0], m.group('scheme'))
 
79
                self.assertEqual(scheme_and_path[1], m.group('path'))
 
80
 
 
81
        # Local paths
 
82
        test_one('/path', None)
 
83
        test_one('C:/path', None)
 
84
        test_one('../path/to/foo', None)
 
85
        test_one(u'../path/to/fo\xe5', None)
 
86
 
 
87
        # Real URLS
 
88
        test_one('http://host/path/', ('http', 'host/path/'))
 
89
        test_one('sftp://host/path/to/foo', ('sftp', 'host/path/to/foo'))
 
90
        test_one('file:///usr/bin', ('file', '/usr/bin'))
 
91
        test_one('file:///C:/Windows', ('file', '/C:/Windows'))
 
92
        test_one('file:///C|/Windows', ('file', '/C|/Windows'))
 
93
        test_one(u'readonly+sftp://host/path/\xe5', ('readonly+sftp', u'host/path/\xe5'))
 
94
 
 
95
        # Weird stuff
 
96
        # Can't have slashes or colons in the scheme
 
97
        test_one('/path/to/://foo', None)
 
98
        test_one('path:path://foo', None)
 
99
        # Must have more than one character for scheme
 
100
        test_one('C://foo', None)
 
101
        test_one('ab://foo', ('ab', 'foo'))
 
102
 
63
103
    def test_dirname(self):
64
104
        # Test bzrlib.urlutils.dirname()
65
105
        dirname = urlutils.dirname