Mercurial > hg
annotate tests/test-url.py @ 29172:2ea9c9aa6e60
hg: limit HGUNICODEPEDANTRY to py2
reload is not available in py3, and py3 is fatal anyway
author | timeless <timeless@mozdev.org> |
---|---|
date | Tue, 05 Apr 2016 01:35:36 +0000 |
parents | 63fe5ddb8715 |
children | 676f4d0e3a7b |
rev | line source |
---|---|
28914
63fe5ddb8715
tests: make test-url use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28677
diff
changeset
|
1 from __future__ import absolute_import, print_function |
63fe5ddb8715
tests: make test-url use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28677
diff
changeset
|
2 |
63fe5ddb8715
tests: make test-url use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28677
diff
changeset
|
3 import doctest |
15398
474279be5add
tests: fix readline escape characters in heredoctest.py/test-url.py
Brodie Rao <brodie@bitheap.org>
parents:
15018
diff
changeset
|
4 import os |
12592
f2937d6492c5
url: verify correctness of https server certificates (issue2407)
Mads Kiilerich <mads@kiilerich.com>
parents:
diff
changeset
|
5 |
f2937d6492c5
url: verify correctness of https server certificates (issue2407)
Mads Kiilerich <mads@kiilerich.com>
parents:
diff
changeset
|
6 def check(a, b): |
f2937d6492c5
url: verify correctness of https server certificates (issue2407)
Mads Kiilerich <mads@kiilerich.com>
parents:
diff
changeset
|
7 if a != b: |
28677
2903558a6991
py3: make test-url use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
26421
diff
changeset
|
8 print((a, b)) |
12592
f2937d6492c5
url: verify correctness of https server certificates (issue2407)
Mads Kiilerich <mads@kiilerich.com>
parents:
diff
changeset
|
9 |
12606
5c8353692123
test-url: refactor with shorter lines
Martin Geisler <mg@aragost.com>
parents:
12592
diff
changeset
|
10 def cert(cn): |
20685
56b1f39dd0c1
test-url: move from dict() construction to {} literals
Augie Fackler <raf@durin42.com>
parents:
15611
diff
changeset
|
11 return {'subject': ((('commonName', cn),),)} |
12606
5c8353692123
test-url: refactor with shorter lines
Martin Geisler <mg@aragost.com>
parents:
12592
diff
changeset
|
12 |
28914
63fe5ddb8715
tests: make test-url use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28677
diff
changeset
|
13 from mercurial import ( |
63fe5ddb8715
tests: make test-url use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28677
diff
changeset
|
14 sslutil, |
63fe5ddb8715
tests: make test-url use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28677
diff
changeset
|
15 ) |
12592
f2937d6492c5
url: verify correctness of https server certificates (issue2407)
Mads Kiilerich <mads@kiilerich.com>
parents:
diff
changeset
|
16 |
28914
63fe5ddb8715
tests: make test-url use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28677
diff
changeset
|
17 _verifycert = sslutil._verifycert |
12724
66e7ba85585b
test-url: remove trailing whitespace
Augie Fackler <durin42@gmail.com>
parents:
12606
diff
changeset
|
18 # Test non-wildcard certificates |
12606
5c8353692123
test-url: refactor with shorter lines
Martin Geisler <mg@aragost.com>
parents:
12592
diff
changeset
|
19 check(_verifycert(cert('example.com'), 'example.com'), |
5c8353692123
test-url: refactor with shorter lines
Martin Geisler <mg@aragost.com>
parents:
12592
diff
changeset
|
20 None) |
5c8353692123
test-url: refactor with shorter lines
Martin Geisler <mg@aragost.com>
parents:
12592
diff
changeset
|
21 check(_verifycert(cert('example.com'), 'www.example.com'), |
5c8353692123
test-url: refactor with shorter lines
Martin Geisler <mg@aragost.com>
parents:
12592
diff
changeset
|
22 'certificate is for example.com') |
5c8353692123
test-url: refactor with shorter lines
Martin Geisler <mg@aragost.com>
parents:
12592
diff
changeset
|
23 check(_verifycert(cert('www.example.com'), 'example.com'), |
5c8353692123
test-url: refactor with shorter lines
Martin Geisler <mg@aragost.com>
parents:
12592
diff
changeset
|
24 'certificate is for www.example.com') |
12592
f2937d6492c5
url: verify correctness of https server certificates (issue2407)
Mads Kiilerich <mads@kiilerich.com>
parents:
diff
changeset
|
25 |
f2937d6492c5
url: verify correctness of https server certificates (issue2407)
Mads Kiilerich <mads@kiilerich.com>
parents:
diff
changeset
|
26 # Test wildcard certificates |
12606
5c8353692123
test-url: refactor with shorter lines
Martin Geisler <mg@aragost.com>
parents:
12592
diff
changeset
|
27 check(_verifycert(cert('*.example.com'), 'www.example.com'), |
5c8353692123
test-url: refactor with shorter lines
Martin Geisler <mg@aragost.com>
parents:
12592
diff
changeset
|
28 None) |
5c8353692123
test-url: refactor with shorter lines
Martin Geisler <mg@aragost.com>
parents:
12592
diff
changeset
|
29 check(_verifycert(cert('*.example.com'), 'example.com'), |
5c8353692123
test-url: refactor with shorter lines
Martin Geisler <mg@aragost.com>
parents:
12592
diff
changeset
|
30 'certificate is for *.example.com') |
5c8353692123
test-url: refactor with shorter lines
Martin Geisler <mg@aragost.com>
parents:
12592
diff
changeset
|
31 check(_verifycert(cert('*.example.com'), 'w.w.example.com'), |
5c8353692123
test-url: refactor with shorter lines
Martin Geisler <mg@aragost.com>
parents:
12592
diff
changeset
|
32 'certificate is for *.example.com') |
12592
f2937d6492c5
url: verify correctness of https server certificates (issue2407)
Mads Kiilerich <mads@kiilerich.com>
parents:
diff
changeset
|
33 |
13249
75d0c38a0bca
url: check subjectAltName when verifying ssl certificate
Yuya Nishihara <yuya@tcha.org>
parents:
13248
diff
changeset
|
34 # Test subjectAltName |
75d0c38a0bca
url: check subjectAltName when verifying ssl certificate
Yuya Nishihara <yuya@tcha.org>
parents:
13248
diff
changeset
|
35 san_cert = {'subject': ((('commonName', 'example.com'),),), |
75d0c38a0bca
url: check subjectAltName when verifying ssl certificate
Yuya Nishihara <yuya@tcha.org>
parents:
13248
diff
changeset
|
36 'subjectAltName': (('DNS', '*.example.net'), |
75d0c38a0bca
url: check subjectAltName when verifying ssl certificate
Yuya Nishihara <yuya@tcha.org>
parents:
13248
diff
changeset
|
37 ('DNS', 'example.net'))} |
75d0c38a0bca
url: check subjectAltName when verifying ssl certificate
Yuya Nishihara <yuya@tcha.org>
parents:
13248
diff
changeset
|
38 check(_verifycert(san_cert, 'example.net'), |
75d0c38a0bca
url: check subjectAltName when verifying ssl certificate
Yuya Nishihara <yuya@tcha.org>
parents:
13248
diff
changeset
|
39 None) |
75d0c38a0bca
url: check subjectAltName when verifying ssl certificate
Yuya Nishihara <yuya@tcha.org>
parents:
13248
diff
changeset
|
40 check(_verifycert(san_cert, 'foo.example.net'), |
75d0c38a0bca
url: check subjectAltName when verifying ssl certificate
Yuya Nishihara <yuya@tcha.org>
parents:
13248
diff
changeset
|
41 None) |
14666
27b080aa880a
sslutil: fall back to commonName when no dNSName in subjectAltName (issue2798)
Nicolas Bareil <nico@chdir.org>
parents:
14313
diff
changeset
|
42 # no fallback to subject commonName when subjectAltName has DNS |
13249
75d0c38a0bca
url: check subjectAltName when verifying ssl certificate
Yuya Nishihara <yuya@tcha.org>
parents:
13248
diff
changeset
|
43 check(_verifycert(san_cert, 'example.com'), |
75d0c38a0bca
url: check subjectAltName when verifying ssl certificate
Yuya Nishihara <yuya@tcha.org>
parents:
13248
diff
changeset
|
44 'certificate is for *.example.net, example.net') |
14666
27b080aa880a
sslutil: fall back to commonName when no dNSName in subjectAltName (issue2798)
Nicolas Bareil <nico@chdir.org>
parents:
14313
diff
changeset
|
45 # fallback to subject commonName when no DNS in subjectAltName |
27b080aa880a
sslutil: fall back to commonName when no dNSName in subjectAltName (issue2798)
Nicolas Bareil <nico@chdir.org>
parents:
14313
diff
changeset
|
46 san_cert = {'subject': ((('commonName', 'example.com'),),), |
27b080aa880a
sslutil: fall back to commonName when no dNSName in subjectAltName (issue2798)
Nicolas Bareil <nico@chdir.org>
parents:
14313
diff
changeset
|
47 'subjectAltName': (('IP Address', '8.8.8.8'),)} |
27b080aa880a
sslutil: fall back to commonName when no dNSName in subjectAltName (issue2798)
Nicolas Bareil <nico@chdir.org>
parents:
14313
diff
changeset
|
48 check(_verifycert(san_cert, 'example.com'), None) |
13249
75d0c38a0bca
url: check subjectAltName when verifying ssl certificate
Yuya Nishihara <yuya@tcha.org>
parents:
13248
diff
changeset
|
49 |
12592
f2937d6492c5
url: verify correctness of https server certificates (issue2407)
Mads Kiilerich <mads@kiilerich.com>
parents:
diff
changeset
|
50 # Avoid some pitfalls |
12606
5c8353692123
test-url: refactor with shorter lines
Martin Geisler <mg@aragost.com>
parents:
12592
diff
changeset
|
51 check(_verifycert(cert('*.foo'), 'foo'), |
5c8353692123
test-url: refactor with shorter lines
Martin Geisler <mg@aragost.com>
parents:
12592
diff
changeset
|
52 'certificate is for *.foo') |
5c8353692123
test-url: refactor with shorter lines
Martin Geisler <mg@aragost.com>
parents:
12592
diff
changeset
|
53 check(_verifycert(cert('*o'), 'foo'), |
5c8353692123
test-url: refactor with shorter lines
Martin Geisler <mg@aragost.com>
parents:
12592
diff
changeset
|
54 'certificate is for *o') |
12592
f2937d6492c5
url: verify correctness of https server certificates (issue2407)
Mads Kiilerich <mads@kiilerich.com>
parents:
diff
changeset
|
55 |
12742
6ab4a7d3c179
url: validity (notBefore/notAfter) is checked by OpenSSL (issue2407)
Mads Kiilerich <mads@kiilerich.com>
parents:
12738
diff
changeset
|
56 check(_verifycert({'subject': ()}, |
12606
5c8353692123
test-url: refactor with shorter lines
Martin Geisler <mg@aragost.com>
parents:
12592
diff
changeset
|
57 'example.com'), |
13249
75d0c38a0bca
url: check subjectAltName when verifying ssl certificate
Yuya Nishihara <yuya@tcha.org>
parents:
13248
diff
changeset
|
58 'no commonName or subjectAltName found in certificate') |
12592
f2937d6492c5
url: verify correctness of https server certificates (issue2407)
Mads Kiilerich <mads@kiilerich.com>
parents:
diff
changeset
|
59 check(_verifycert(None, 'example.com'), |
12606
5c8353692123
test-url: refactor with shorter lines
Martin Geisler <mg@aragost.com>
parents:
12592
diff
changeset
|
60 'no certificate received') |
13248
00411a4fa1bb
url: fix UnicodeDecodeError on certificate verification error
Yuya Nishihara <yuya@tcha.org>
parents:
12865
diff
changeset
|
61 |
14666
27b080aa880a
sslutil: fall back to commonName when no dNSName in subjectAltName (issue2798)
Nicolas Bareil <nico@chdir.org>
parents:
14313
diff
changeset
|
62 # Unicode (IDN) certname isn't supported |
27b080aa880a
sslutil: fall back to commonName when no dNSName in subjectAltName (issue2798)
Nicolas Bareil <nico@chdir.org>
parents:
14313
diff
changeset
|
63 check(_verifycert(cert(u'\u4f8b.jp'), 'example.jp'), |
27b080aa880a
sslutil: fall back to commonName when no dNSName in subjectAltName (issue2798)
Nicolas Bareil <nico@chdir.org>
parents:
14313
diff
changeset
|
64 'IDN in certificate not supported') |
27b080aa880a
sslutil: fall back to commonName when no dNSName in subjectAltName (issue2798)
Nicolas Bareil <nico@chdir.org>
parents:
14313
diff
changeset
|
65 |
13770 | 66 def test_url(): |
67 """ | |
14076
924c82157d46
url: move URL parsing functions into util to improve startup time
Brodie Rao <brodie@bitheap.org>
parents:
13848
diff
changeset
|
68 >>> from mercurial.util import url |
13770 | 69 |
70 This tests for edge cases in url.URL's parsing algorithm. Most of | |
71 these aren't useful for documentation purposes, so they aren't | |
72 part of the class's doc tests. | |
73 | |
74 Query strings and fragments: | |
75 | |
76 >>> url('http://host/a?b#c') | |
77 <url scheme: 'http', host: 'host', path: 'a', query: 'b', fragment: 'c'> | |
78 >>> url('http://host/a?') | |
79 <url scheme: 'http', host: 'host', path: 'a'> | |
80 >>> url('http://host/a#b#c') | |
81 <url scheme: 'http', host: 'host', path: 'a', fragment: 'b#c'> | |
82 >>> url('http://host/a#b?c') | |
83 <url scheme: 'http', host: 'host', path: 'a', fragment: 'b?c'> | |
84 >>> url('http://host/?a#b') | |
85 <url scheme: 'http', host: 'host', path: '', query: 'a', fragment: 'b'> | |
13827
f1823b9f073b
url: nuke some newly-introduced underbars in identifiers
Matt Mackall <mpm@selenic.com>
parents:
13817
diff
changeset
|
86 >>> url('http://host/?a#b', parsequery=False) |
13770 | 87 <url scheme: 'http', host: 'host', path: '?a', fragment: 'b'> |
13827
f1823b9f073b
url: nuke some newly-introduced underbars in identifiers
Matt Mackall <mpm@selenic.com>
parents:
13817
diff
changeset
|
88 >>> url('http://host/?a#b', parsefragment=False) |
13770 | 89 <url scheme: 'http', host: 'host', path: '', query: 'a#b'> |
13827
f1823b9f073b
url: nuke some newly-introduced underbars in identifiers
Matt Mackall <mpm@selenic.com>
parents:
13817
diff
changeset
|
90 >>> url('http://host/?a#b', parsequery=False, parsefragment=False) |
13770 | 91 <url scheme: 'http', host: 'host', path: '?a#b'> |
92 | |
93 IPv6 addresses: | |
94 | |
95 >>> url('ldap://[2001:db8::7]/c=GB?objectClass?one') | |
96 <url scheme: 'ldap', host: '[2001:db8::7]', path: 'c=GB', | |
97 query: 'objectClass?one'> | |
98 >>> url('ldap://joe:xxx@[2001:db8::7]:80/c=GB?objectClass?one') | |
99 <url scheme: 'ldap', user: 'joe', passwd: 'xxx', host: '[2001:db8::7]', | |
100 port: '80', path: 'c=GB', query: 'objectClass?one'> | |
101 | |
102 Missing scheme, host, etc.: | |
103 | |
104 >>> url('://192.0.2.16:80/') | |
105 <url path: '://192.0.2.16:80/'> | |
26421
4b0fc75f9403
urls: bulk-change primary website URLs
Matt Mackall <mpm@selenic.com>
parents:
20685
diff
changeset
|
106 >>> url('https://mercurial-scm.org') |
4b0fc75f9403
urls: bulk-change primary website URLs
Matt Mackall <mpm@selenic.com>
parents:
20685
diff
changeset
|
107 <url scheme: 'https', host: 'mercurial-scm.org'> |
13770 | 108 >>> url('/foo') |
109 <url path: '/foo'> | |
110 >>> url('bundle:/foo') | |
111 <url scheme: 'bundle', path: '/foo'> | |
112 >>> url('a?b#c') | |
113 <url path: 'a?b', fragment: 'c'> | |
114 >>> url('http://x.com?arg=/foo') | |
115 <url scheme: 'http', host: 'x.com', query: 'arg=/foo'> | |
116 >>> url('http://joe:xxx@/foo') | |
117 <url scheme: 'http', user: 'joe', passwd: 'xxx', path: 'foo'> | |
118 | |
119 Just a scheme and a path: | |
120 | |
121 >>> url('mailto:John.Doe@example.com') | |
122 <url scheme: 'mailto', path: 'John.Doe@example.com'> | |
123 >>> url('a:b:c:d') | |
13808 | 124 <url path: 'a:b:c:d'> |
125 >>> url('aa:bb:cc:dd') | |
126 <url scheme: 'aa', path: 'bb:cc:dd'> | |
13770 | 127 |
128 SSH examples: | |
129 | |
130 >>> url('ssh://joe@host//home/joe') | |
131 <url scheme: 'ssh', user: 'joe', host: 'host', path: '/home/joe'> | |
132 >>> url('ssh://joe:xxx@host/src') | |
133 <url scheme: 'ssh', user: 'joe', passwd: 'xxx', host: 'host', path: 'src'> | |
134 >>> url('ssh://joe:xxx@host') | |
135 <url scheme: 'ssh', user: 'joe', passwd: 'xxx', host: 'host'> | |
136 >>> url('ssh://joe@host') | |
137 <url scheme: 'ssh', user: 'joe', host: 'host'> | |
138 >>> url('ssh://host') | |
139 <url scheme: 'ssh', host: 'host'> | |
140 >>> url('ssh://') | |
141 <url scheme: 'ssh'> | |
142 >>> url('ssh:') | |
143 <url scheme: 'ssh'> | |
144 | |
145 Non-numeric port: | |
146 | |
147 >>> url('http://example.com:dd') | |
148 <url scheme: 'http', host: 'example.com', port: 'dd'> | |
149 >>> url('ssh://joe:xxx@host:ssh/foo') | |
150 <url scheme: 'ssh', user: 'joe', passwd: 'xxx', host: 'host', port: 'ssh', | |
151 path: 'foo'> | |
152 | |
153 Bad authentication credentials: | |
154 | |
155 >>> url('http://joe@joeville:123@4:@host/a?b#c') | |
156 <url scheme: 'http', user: 'joe@joeville', passwd: '123@4:', | |
157 host: 'host', path: 'a', query: 'b', fragment: 'c'> | |
158 >>> url('http://!*#?/@!*#?/:@host/a?b#c') | |
159 <url scheme: 'http', host: '!*', fragment: '?/@!*#?/:@host/a?b#c'> | |
160 >>> url('http://!*#?@!*#?:@host/a?b#c') | |
161 <url scheme: 'http', host: '!*', fragment: '?@!*#?:@host/a?b#c'> | |
162 >>> url('http://!*@:!*@@host/a?b#c') | |
163 <url scheme: 'http', user: '!*@', passwd: '!*@', host: 'host', | |
164 path: 'a', query: 'b', fragment: 'c'> | |
165 | |
166 File paths: | |
167 | |
168 >>> url('a/b/c/d.g.f') | |
169 <url path: 'a/b/c/d.g.f'> | |
170 >>> url('/x///z/y/') | |
171 <url path: '/x///z/y/'> | |
13848
b2798c1defff
url: be stricter about detecting schemes
Brodie Rao <brodie@bitheap.org>
parents:
13827
diff
changeset
|
172 >>> url('/foo:bar') |
b2798c1defff
url: be stricter about detecting schemes
Brodie Rao <brodie@bitheap.org>
parents:
13827
diff
changeset
|
173 <url path: '/foo:bar'> |
b2798c1defff
url: be stricter about detecting schemes
Brodie Rao <brodie@bitheap.org>
parents:
13827
diff
changeset
|
174 >>> url('\\\\foo:bar') |
b2798c1defff
url: be stricter about detecting schemes
Brodie Rao <brodie@bitheap.org>
parents:
13827
diff
changeset
|
175 <url path: '\\\\foo:bar'> |
b2798c1defff
url: be stricter about detecting schemes
Brodie Rao <brodie@bitheap.org>
parents:
13827
diff
changeset
|
176 >>> url('./foo:bar') |
b2798c1defff
url: be stricter about detecting schemes
Brodie Rao <brodie@bitheap.org>
parents:
13827
diff
changeset
|
177 <url path: './foo:bar'> |
13770 | 178 |
13817
7f18bab2c0b0
url: abort on file:// URLs with non-localhost hosts
Brodie Rao <brodie@bitheap.org>
parents:
13808
diff
changeset
|
179 Non-localhost file URL: |
7f18bab2c0b0
url: abort on file:// URLs with non-localhost hosts
Brodie Rao <brodie@bitheap.org>
parents:
13808
diff
changeset
|
180 |
26421
4b0fc75f9403
urls: bulk-change primary website URLs
Matt Mackall <mpm@selenic.com>
parents:
20685
diff
changeset
|
181 >>> u = url('file://mercurial-scm.org/foo') |
13817
7f18bab2c0b0
url: abort on file:// URLs with non-localhost hosts
Brodie Rao <brodie@bitheap.org>
parents:
13808
diff
changeset
|
182 Traceback (most recent call last): |
7f18bab2c0b0
url: abort on file:// URLs with non-localhost hosts
Brodie Rao <brodie@bitheap.org>
parents:
13808
diff
changeset
|
183 File "<stdin>", line 1, in ? |
7f18bab2c0b0
url: abort on file:// URLs with non-localhost hosts
Brodie Rao <brodie@bitheap.org>
parents:
13808
diff
changeset
|
184 Abort: file:// URLs can only refer to localhost |
7f18bab2c0b0
url: abort on file:// URLs with non-localhost hosts
Brodie Rao <brodie@bitheap.org>
parents:
13808
diff
changeset
|
185 |
13770 | 186 Empty URL: |
187 | |
188 >>> u = url('') | |
189 >>> u | |
190 <url path: ''> | |
191 >>> str(u) | |
192 '' | |
193 | |
194 Empty path with query string: | |
195 | |
196 >>> str(url('http://foo/?bar')) | |
197 'http://foo/?bar' | |
198 | |
199 Invalid path: | |
200 | |
201 >>> u = url('http://foo/bar') | |
202 >>> u.path = 'bar' | |
203 >>> str(u) | |
204 'http://foo/bar' | |
205 | |
14313
a389dd285282
util: make str(url) return file:/// for abs paths again
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14204
diff
changeset
|
206 >>> u = url('file:/foo/bar/baz') |
a389dd285282
util: make str(url) return file:/// for abs paths again
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14204
diff
changeset
|
207 >>> u |
a389dd285282
util: make str(url) return file:/// for abs paths again
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14204
diff
changeset
|
208 <url scheme: 'file', path: '/foo/bar/baz'> |
a389dd285282
util: make str(url) return file:/// for abs paths again
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14204
diff
changeset
|
209 >>> str(u) |
a389dd285282
util: make str(url) return file:/// for abs paths again
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14204
diff
changeset
|
210 'file:///foo/bar/baz' |
15018
e89f62dcd723
url: really handle urls of the form file:///c:/foo/bar/ correctly
Mads Kiilerich <mads@kiilerich.com>
parents:
14666
diff
changeset
|
211 >>> u.localpath() |
e89f62dcd723
url: really handle urls of the form file:///c:/foo/bar/ correctly
Mads Kiilerich <mads@kiilerich.com>
parents:
14666
diff
changeset
|
212 '/foo/bar/baz' |
14313
a389dd285282
util: make str(url) return file:/// for abs paths again
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14204
diff
changeset
|
213 |
13770 | 214 >>> u = url('file:///foo/bar/baz') |
215 >>> u | |
216 <url scheme: 'file', path: '/foo/bar/baz'> | |
217 >>> str(u) | |
14313
a389dd285282
util: make str(url) return file:/// for abs paths again
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14204
diff
changeset
|
218 'file:///foo/bar/baz' |
15018
e89f62dcd723
url: really handle urls of the form file:///c:/foo/bar/ correctly
Mads Kiilerich <mads@kiilerich.com>
parents:
14666
diff
changeset
|
219 >>> u.localpath() |
e89f62dcd723
url: really handle urls of the form file:///c:/foo/bar/ correctly
Mads Kiilerich <mads@kiilerich.com>
parents:
14666
diff
changeset
|
220 '/foo/bar/baz' |
e89f62dcd723
url: really handle urls of the form file:///c:/foo/bar/ correctly
Mads Kiilerich <mads@kiilerich.com>
parents:
14666
diff
changeset
|
221 |
e89f62dcd723
url: really handle urls of the form file:///c:/foo/bar/ correctly
Mads Kiilerich <mads@kiilerich.com>
parents:
14666
diff
changeset
|
222 >>> u = url('file:///f:oo/bar/baz') |
e89f62dcd723
url: really handle urls of the form file:///c:/foo/bar/ correctly
Mads Kiilerich <mads@kiilerich.com>
parents:
14666
diff
changeset
|
223 >>> u |
e89f62dcd723
url: really handle urls of the form file:///c:/foo/bar/ correctly
Mads Kiilerich <mads@kiilerich.com>
parents:
14666
diff
changeset
|
224 <url scheme: 'file', path: 'f:oo/bar/baz'> |
e89f62dcd723
url: really handle urls of the form file:///c:/foo/bar/ correctly
Mads Kiilerich <mads@kiilerich.com>
parents:
14666
diff
changeset
|
225 >>> str(u) |
15611 | 226 'file:///f:oo/bar/baz' |
15018
e89f62dcd723
url: really handle urls of the form file:///c:/foo/bar/ correctly
Mads Kiilerich <mads@kiilerich.com>
parents:
14666
diff
changeset
|
227 >>> u.localpath() |
e89f62dcd723
url: really handle urls of the form file:///c:/foo/bar/ correctly
Mads Kiilerich <mads@kiilerich.com>
parents:
14666
diff
changeset
|
228 'f:oo/bar/baz' |
14313
a389dd285282
util: make str(url) return file:/// for abs paths again
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14204
diff
changeset
|
229 |
15496
396e83d635a6
url: handle file://localhost/c:/foo "correctly"
Mads Kiilerich <mads@kiilerich.com>
parents:
15398
diff
changeset
|
230 >>> u = url('file://localhost/f:oo/bar/baz') |
396e83d635a6
url: handle file://localhost/c:/foo "correctly"
Mads Kiilerich <mads@kiilerich.com>
parents:
15398
diff
changeset
|
231 >>> u |
396e83d635a6
url: handle file://localhost/c:/foo "correctly"
Mads Kiilerich <mads@kiilerich.com>
parents:
15398
diff
changeset
|
232 <url scheme: 'file', host: 'localhost', path: 'f:oo/bar/baz'> |
396e83d635a6
url: handle file://localhost/c:/foo "correctly"
Mads Kiilerich <mads@kiilerich.com>
parents:
15398
diff
changeset
|
233 >>> str(u) |
15513 | 234 'file://localhost/f:oo/bar/baz' |
15496
396e83d635a6
url: handle file://localhost/c:/foo "correctly"
Mads Kiilerich <mads@kiilerich.com>
parents:
15398
diff
changeset
|
235 >>> u.localpath() |
396e83d635a6
url: handle file://localhost/c:/foo "correctly"
Mads Kiilerich <mads@kiilerich.com>
parents:
15398
diff
changeset
|
236 'f:oo/bar/baz' |
396e83d635a6
url: handle file://localhost/c:/foo "correctly"
Mads Kiilerich <mads@kiilerich.com>
parents:
15398
diff
changeset
|
237 |
14313
a389dd285282
util: make str(url) return file:/// for abs paths again
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14204
diff
changeset
|
238 >>> u = url('file:foo/bar/baz') |
a389dd285282
util: make str(url) return file:/// for abs paths again
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14204
diff
changeset
|
239 >>> u |
a389dd285282
util: make str(url) return file:/// for abs paths again
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14204
diff
changeset
|
240 <url scheme: 'file', path: 'foo/bar/baz'> |
a389dd285282
util: make str(url) return file:/// for abs paths again
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14204
diff
changeset
|
241 >>> str(u) |
a389dd285282
util: make str(url) return file:/// for abs paths again
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14204
diff
changeset
|
242 'file:foo/bar/baz' |
15018
e89f62dcd723
url: really handle urls of the form file:///c:/foo/bar/ correctly
Mads Kiilerich <mads@kiilerich.com>
parents:
14666
diff
changeset
|
243 >>> u.localpath() |
e89f62dcd723
url: really handle urls of the form file:///c:/foo/bar/ correctly
Mads Kiilerich <mads@kiilerich.com>
parents:
14666
diff
changeset
|
244 'foo/bar/baz' |
13770 | 245 """ |
246 | |
15398
474279be5add
tests: fix readline escape characters in heredoctest.py/test-url.py
Brodie Rao <brodie@bitheap.org>
parents:
15018
diff
changeset
|
247 if 'TERM' in os.environ: |
474279be5add
tests: fix readline escape characters in heredoctest.py/test-url.py
Brodie Rao <brodie@bitheap.org>
parents:
15018
diff
changeset
|
248 del os.environ['TERM'] |
474279be5add
tests: fix readline escape characters in heredoctest.py/test-url.py
Brodie Rao <brodie@bitheap.org>
parents:
15018
diff
changeset
|
249 |
13770 | 250 doctest.testmod(optionflags=doctest.NORMALIZE_WHITESPACE) |