CARVIEW |
Select Language
HTTP/2 302
server: nginx
date: Sat, 19 Jul 2025 19:55:26 GMT
content-type: text/plain; charset=utf-8
content-length: 0
x-archive-redirect-reason: found capture at 20071208093040
location: https://web.archive.org/web/20071208093040/https://wiki.python.org/moin/AlternativePathModuleTests
server-timing: captures_list;dur=0.612283, exclusion.robots;dur=0.028040, exclusion.robots.policy;dur=0.014091, esindex;dur=0.014877, cdx.remote;dur=6.582821, LoadShardBlock;dur=476.357490, PetaboxLoader3.resolve;dur=313.227726, PetaboxLoader3.datanode;dur=92.635518
x-app-server: wwwb-app203
x-ts: 302
x-tr: 516
server-timing: TR;dur=0,Tw;dur=0,Tc;dur=0
set-cookie: SERVER=wwwb-app203; path=/
x-location: All
x-rl: 0
x-na: 0
x-page-cache: MISS
server-timing: MISS
x-nid: DigitalOcean
referrer-policy: no-referrer-when-downgrade
permissions-policy: interest-cohort=()
HTTP/2 200
server: nginx
date: Sat, 19 Jul 2025 19:55:27 GMT
content-type: text/html;charset=utf-8
x-archive-orig-date: Sat, 08 Dec 2007 09:30:39 GMT
x-archive-orig-server: Apache/2.0.54 (Debian GNU/Linux) mod_fastcgi/2.4.2
x-archive-orig-connection: close
x-archive-guessed-content-type: text/html
x-archive-guessed-charset: utf-8
memento-datetime: Sat, 08 Dec 2007 09:30:40 GMT
link: ; rel="original", ; rel="timemap"; type="application/link-format", ; rel="timegate", ; rel="first memento"; datetime="Mon, 11 Sep 2006 16:29:50 GMT", ; rel="prev memento"; datetime="Sun, 05 Aug 2007 22:01:38 GMT", ; rel="memento"; datetime="Sat, 08 Dec 2007 09:30:40 GMT", ; rel="next memento"; datetime="Fri, 12 Aug 2011 01:50:11 GMT", ; rel="last memento"; datetime="Sun, 21 Jul 2024 04:26:29 GMT"
content-security-policy: default-src 'self' 'unsafe-eval' 'unsafe-inline' data: blob: archive.org web.archive.org web-static.archive.org wayback-api.archive.org athena.archive.org analytics.archive.org pragma.archivelab.org wwwb-events.archive.org
x-archive-src: 52_1_20071208084132_crawl105-c/52_1_20071208092836_crawl107.arc.gz
server-timing: captures_list;dur=0.776364, exclusion.robots;dur=0.025848, exclusion.robots.policy;dur=0.012008, esindex;dur=0.014238, cdx.remote;dur=17.553646, LoadShardBlock;dur=90.383410, PetaboxLoader3.datanode;dur=111.653099, load_resource;dur=311.070124, PetaboxLoader3.resolve;dur=154.092094
x-app-server: wwwb-app203
x-ts: 200
x-tr: 529
server-timing: TR;dur=0,Tw;dur=0,Tc;dur=0
x-location: All
x-rl: 0
x-na: 0
x-page-cache: MISS
server-timing: MISS
x-nid: DigitalOcean
referrer-policy: no-referrer-when-downgrade
permissions-policy: interest-cohort=()
content-encoding: gzip
AlternativePathModuleTests - PythonInfo Wiki
AlternativePathModuleTests
1 ======================================
2 doctest for path.py
3
4 Uncomplete, and tests POSIX paths only
5 ======================================
6
7 >>> from mypath import path
8
9 # Test root
10
11 >>> path.ROOT
12 path.ROOT
13
14 >>> path.ROOT == path.ROOT
15 True
16 >>> path.ROOT < path.ROOT
17 False
18 >>> path.ROOT > path.ROOT
19 False
20
21 >>> path.ROOT == 'e'
22 False
23 >>> path.ROOT < 'h'
24 True
25 >>> path.ROOT > 'b'
26 False
27 >>> path.ROOT > 3
28 Traceback (most recent call last):
29 ...
30 TypeError: Comparison not defined
31
32 >>> 'a' == path.ROOT
33 False
34 >>> 'a' < path.ROOT
35 False
36 >>> 'a' > path.ROOT
37 True
38 >>> 3 > path.ROOT
39 Traceback (most recent call last):
40 ...
41 TypeError: Comparison not defined
42
43
44 # Basic path creation
45
46 >>> path('/bin/arch')
47 path('/bin/arch')
48 >>> p = _
49 >>> p[0]
50 path.ROOT
51 >>> p[1]
52 'bin'
53 >>> p[2]
54 'arch'
55 >>> len(p)
56 3
57 >>> path('hello/what')
58 path('hello/what')
59 >>> p = _
60 >>> p[0]
61 'hello'
62 >>> p[1]
63 'what'
64 >>> len(p)
65 2
66 >>> path('.')
67 path('.')
68 >>> len(_)
69 0
70 >>> path('')
71 path('.')
72 >>> path()
73 path('.')
74 >>> path('/')
75 path('/')
76
77 # Constructing from a string
78
79 >>> path('hello//what')
80 path('hello/what')
81 >>> path('hello//what/')
82 path('hello/what')
83 >>> path('/hello//what/')
84 path('/hello/what')
85 >>> path('//hello//what/')
86 Traceback (most recent call last):
87 ...
88 NotImplementedError: Paths with two leading slashes aren't supported.
89 >>> path('///hello//what/')
90 path('/hello/what')
91
92 # Constructing from an iterable
93
94 >>> path(['hello', 'how'])
95 path('hello/how')
96 >>> path([path.ROOT, 'hello', 'how'])
97 path('/hello/how')
98 >>> path(['hello', path.ROOT, 'how'])
99 Traceback (most recent call last):
100 ...
101 TypeError: Element path.ROOT is of a wrong type
102
103 # Concatenation
104
105 >>> path('hello/a') + path('b')
106 path('hello/a/b')
107 >>> path('hello/a') + 'b'
108 path('hello/a/b')
109 >>> path('hello/a') + 'b/c'
110 path('hello/a/b/c')
111 >>> 'b/c' + path('hello/a')
112 path('b/c/hello/a')
113 >>> 'b/c' + path('/hello/a')
114 Traceback (most recent call last):
115 ...
116 ValueError: Right operand should be a relative path
117 >>> path('hello/a') + '/b/c'
118 Traceback (most recent call last):
119 ...
120 ValueError: Right operand should be a relative path
121
122 # Slicing
123
124 >>> p = path('/hello/a')
125 >>> p[:2]
126 path('/hello')
127 >>> p[-1]
128 'a'
129 >>> p[:-1]
130 path('/hello')
131
132 # Multiplication
133
134 >>> path('hello/a') * 3
135 path('hello/a/hello/a/hello/a')
136 >>> path('/hello/a') * 3
137 Traceback (most recent call last):
138 ...
139 ValueError: Only relative paths can be multiplied
140
141 >>> 3 * path('hello/a')
142 path('hello/a/hello/a/hello/a')
143 >>> 3 * path('/hello/a')
144 Traceback (most recent call last):
145 ...
146 ValueError: Only relative paths can be multiplied
147
148 # Comparison
149
150 >>> L = ['/home/noam', '/home/allon', '/home/noam2', '/home/bbbb',
151 ... 'home/bbbb', 'home/noam', 'home/noam2', 'home/allon', 'a/b', '/b/c']
152 >>> L.extend([path(x) for x in L])
153 >>> L.sort()
154 >>> L
155 ['/b/c', path('/b/c'), '/home/allon', path('/home/allon'), '/home/bbbb', path('/home/bbbb'), '/home/noam', path('/home/noam'), '/home/noam2', path('/home/noam2'), 'a/b', path('a/b'), 'home/allon', path('home/allon'), 'home/bbbb', path('home/bbbb'), 'home/noam', path('home/noam'), 'home/noam2', path('home/noam2')]
156
157
158
159 # Matching
160
161 >>> path('a/b').match('a/b')
162 True
163 >>> path('a/b').match('a/c')
164 False
165 >>> path('a/b').match('a')
166 False
167 >>> path('a/b').match('a/c*')
168 False
169 >>> path('a/b').match('a/b*')
170 True
171 >>> path('a/b').match('**')
172 True
EditText (last edited 2006-05-02 14:00:58 by NoamRaphael)
- Login
- Navigation
- Actions
- Your recent pages