##// END OF EJS Templates
py3: add b'' prefixes in tests/test-hgweb-no-request-uri.t...
Pulkit Goyal -
r39696:a12916cf default
parent child Browse files
Show More
@@ -1,179 +1,179 b''
1 This tests if hgweb and hgwebdir still work if the REQUEST_URI variable is
1 This tests if hgweb and hgwebdir still work if the REQUEST_URI variable is
2 no longer passed with the request. Instead, SCRIPT_NAME and PATH_INFO
2 no longer passed with the request. Instead, SCRIPT_NAME and PATH_INFO
3 should be used from d74fc8dec2b4 onward to route the request.
3 should be used from d74fc8dec2b4 onward to route the request.
4
4
5 $ hg init repo
5 $ hg init repo
6 $ cd repo
6 $ cd repo
7 $ echo foo > bar
7 $ echo foo > bar
8 $ hg add bar
8 $ hg add bar
9 $ hg commit -m "test"
9 $ hg commit -m "test"
10 $ hg tip
10 $ hg tip
11 changeset: 0:61c9426e69fe
11 changeset: 0:61c9426e69fe
12 tag: tip
12 tag: tip
13 user: test
13 user: test
14 date: Thu Jan 01 00:00:00 1970 +0000
14 date: Thu Jan 01 00:00:00 1970 +0000
15 summary: test
15 summary: test
16
16
17 $ cat > request.py <<EOF
17 $ cat > request.py <<EOF
18 > from __future__ import absolute_import
18 > from __future__ import absolute_import
19 > import os
19 > import os
20 > import sys
20 > import sys
21 > from mercurial.hgweb import (
21 > from mercurial.hgweb import (
22 > hgweb,
22 > hgweb,
23 > hgwebdir,
23 > hgwebdir,
24 > )
24 > )
25 > from mercurial import (
25 > from mercurial import (
26 > util,
26 > util,
27 > )
27 > )
28 > stringio = util.stringio
28 > stringio = util.stringio
29 >
29 >
30 > errors = stringio()
30 > errors = stringio()
31 > input = stringio()
31 > input = stringio()
32 >
32 >
33 > def startrsp(status, headers):
33 > def startrsp(status, headers):
34 > print('---- STATUS')
34 > print('---- STATUS')
35 > print(status)
35 > print(status)
36 > print('---- HEADERS')
36 > print('---- HEADERS')
37 > print([i for i in headers if i[0] != 'ETag'])
37 > print([i for i in headers if i[0] != 'ETag'])
38 > print('---- DATA')
38 > print('---- DATA')
39 > return output.write
39 > return output.write
40 >
40 >
41 > env = {
41 > env = {
42 > 'wsgi.version': (1, 0),
42 > 'wsgi.version': (1, 0),
43 > 'wsgi.url_scheme': 'http',
43 > 'wsgi.url_scheme': 'http',
44 > 'wsgi.errors': errors,
44 > 'wsgi.errors': errors,
45 > 'wsgi.input': input,
45 > 'wsgi.input': input,
46 > 'wsgi.multithread': False,
46 > 'wsgi.multithread': False,
47 > 'wsgi.multiprocess': False,
47 > 'wsgi.multiprocess': False,
48 > 'wsgi.run_once': False,
48 > 'wsgi.run_once': False,
49 > 'REQUEST_METHOD': 'GET',
49 > 'REQUEST_METHOD': 'GET',
50 > 'SCRIPT_NAME': '',
50 > 'SCRIPT_NAME': '',
51 > 'SERVER_NAME': '$LOCALIP',
51 > 'SERVER_NAME': '$LOCALIP',
52 > 'SERVER_PORT': os.environ['HGPORT'],
52 > 'SERVER_PORT': os.environ['HGPORT'],
53 > 'SERVER_PROTOCOL': 'HTTP/1.0'
53 > 'SERVER_PROTOCOL': 'HTTP/1.0'
54 > }
54 > }
55 >
55 >
56 > def process(app):
56 > def process(app):
57 > content = app(env, startrsp)
57 > content = app(env, startrsp)
58 > sys.stdout.write(output.getvalue())
58 > sys.stdout.write(output.getvalue())
59 > sys.stdout.write(''.join(content))
59 > sys.stdout.write(''.join(content))
60 > getattr(content, 'close', lambda : None)()
60 > getattr(content, 'close', lambda : None)()
61 > print('---- ERRORS')
61 > print('---- ERRORS')
62 > print(errors.getvalue())
62 > print(errors.getvalue())
63 >
63 >
64 > output = stringio()
64 > output = stringio()
65 > env['PATH_INFO'] = '/'
65 > env['PATH_INFO'] = '/'
66 > env['QUERY_STRING'] = 'style=atom'
66 > env['QUERY_STRING'] = 'style=atom'
67 > process(hgweb('.', name = 'repo'))
67 > process(hgweb(b'.', name = b'repo'))
68 >
68 >
69 > output = stringio()
69 > output = stringio()
70 > env['PATH_INFO'] = '/file/tip/'
70 > env['PATH_INFO'] = '/file/tip/'
71 > env['QUERY_STRING'] = 'style=raw'
71 > env['QUERY_STRING'] = 'style=raw'
72 > process(hgweb('.', name = 'repo'))
72 > process(hgweb(b'.', name = b'repo'))
73 >
73 >
74 > output = stringio()
74 > output = stringio()
75 > env['PATH_INFO'] = '/'
75 > env['PATH_INFO'] = '/'
76 > env['QUERY_STRING'] = 'style=raw'
76 > env['QUERY_STRING'] = 'style=raw'
77 > process(hgwebdir({'repo': '.'}))
77 > process(hgwebdir({'repo': b'.'}))
78 >
78 >
79 > output = stringio()
79 > output = stringio()
80 > env['PATH_INFO'] = '/repo/file/tip/'
80 > env['PATH_INFO'] = '/repo/file/tip/'
81 > env['QUERY_STRING'] = 'style=raw'
81 > env['QUERY_STRING'] = 'style=raw'
82 > process(hgwebdir({'repo': '.'}))
82 > process(hgwebdir({'repo': b'.'}))
83 > EOF
83 > EOF
84 $ $PYTHON request.py
84 $ $PYTHON request.py
85 ---- STATUS
85 ---- STATUS
86 200 Script output follows
86 200 Script output follows
87 ---- HEADERS
87 ---- HEADERS
88 [('Content-Type', 'application/atom+xml; charset=ascii')]
88 [('Content-Type', 'application/atom+xml; charset=ascii')]
89 ---- DATA
89 ---- DATA
90 <?xml version="1.0" encoding="ascii"?>
90 <?xml version="1.0" encoding="ascii"?>
91 <feed xmlns="http://www.w3.org/2005/Atom">
91 <feed xmlns="http://www.w3.org/2005/Atom">
92 <!-- Changelog -->
92 <!-- Changelog -->
93 <id>http://$LOCALIP:$HGPORT/</id> (glob)
93 <id>http://$LOCALIP:$HGPORT/</id> (glob)
94 <link rel="self" href="http://$LOCALIP:$HGPORT/atom-log"/> (glob)
94 <link rel="self" href="http://$LOCALIP:$HGPORT/atom-log"/> (glob)
95 <link rel="alternate" href="http://$LOCALIP:$HGPORT/"/> (glob)
95 <link rel="alternate" href="http://$LOCALIP:$HGPORT/"/> (glob)
96 <title>repo Changelog</title>
96 <title>repo Changelog</title>
97 <updated>1970-01-01T00:00:00+00:00</updated>
97 <updated>1970-01-01T00:00:00+00:00</updated>
98
98
99 <entry>
99 <entry>
100 <title>[default] test</title>
100 <title>[default] test</title>
101 <id>http://$LOCALIP:$HGPORT/#changeset-61c9426e69fef294feed5e2bbfc97d39944a5b1c</id> (glob)
101 <id>http://$LOCALIP:$HGPORT/#changeset-61c9426e69fef294feed5e2bbfc97d39944a5b1c</id> (glob)
102 <link href="http://$LOCALIP:$HGPORT/rev/61c9426e69fe"/> (glob)
102 <link href="http://$LOCALIP:$HGPORT/rev/61c9426e69fe"/> (glob)
103 <author>
103 <author>
104 <name>test</name>
104 <name>test</name>
105 <email>&#116;&#101;&#115;&#116;</email>
105 <email>&#116;&#101;&#115;&#116;</email>
106 </author>
106 </author>
107 <updated>1970-01-01T00:00:00+00:00</updated>
107 <updated>1970-01-01T00:00:00+00:00</updated>
108 <published>1970-01-01T00:00:00+00:00</published>
108 <published>1970-01-01T00:00:00+00:00</published>
109 <content type="xhtml">
109 <content type="xhtml">
110 <table xmlns="http://www.w3.org/1999/xhtml">
110 <table xmlns="http://www.w3.org/1999/xhtml">
111 <tr>
111 <tr>
112 <th style="text-align:left;">changeset</th>
112 <th style="text-align:left;">changeset</th>
113 <td>61c9426e69fe</td>
113 <td>61c9426e69fe</td>
114 </tr>
114 </tr>
115 <tr>
115 <tr>
116 <th style="text-align:left;">branch</th>
116 <th style="text-align:left;">branch</th>
117 <td>default</td>
117 <td>default</td>
118 </tr>
118 </tr>
119 <tr>
119 <tr>
120 <th style="text-align:left;">bookmark</th>
120 <th style="text-align:left;">bookmark</th>
121 <td></td>
121 <td></td>
122 </tr>
122 </tr>
123 <tr>
123 <tr>
124 <th style="text-align:left;">tag</th>
124 <th style="text-align:left;">tag</th>
125 <td>tip</td>
125 <td>tip</td>
126 </tr>
126 </tr>
127 <tr>
127 <tr>
128 <th style="text-align:left;">user</th>
128 <th style="text-align:left;">user</th>
129 <td>&#116;&#101;&#115;&#116;</td>
129 <td>&#116;&#101;&#115;&#116;</td>
130 </tr>
130 </tr>
131 <tr>
131 <tr>
132 <th style="text-align:left;vertical-align:top;">description</th>
132 <th style="text-align:left;vertical-align:top;">description</th>
133 <td>test</td>
133 <td>test</td>
134 </tr>
134 </tr>
135 <tr>
135 <tr>
136 <th style="text-align:left;vertical-align:top;">files</th>
136 <th style="text-align:left;vertical-align:top;">files</th>
137 <td>bar<br /></td>
137 <td>bar<br /></td>
138 </tr>
138 </tr>
139 </table>
139 </table>
140 </content>
140 </content>
141 </entry>
141 </entry>
142
142
143 </feed>
143 </feed>
144 ---- ERRORS
144 ---- ERRORS
145
145
146 ---- STATUS
146 ---- STATUS
147 200 Script output follows
147 200 Script output follows
148 ---- HEADERS
148 ---- HEADERS
149 [('Content-Type', 'text/plain; charset=ascii')]
149 [('Content-Type', 'text/plain; charset=ascii')]
150 ---- DATA
150 ---- DATA
151
151
152 -rw-r--r-- 4 bar
152 -rw-r--r-- 4 bar
153
153
154
154
155 ---- ERRORS
155 ---- ERRORS
156
156
157 ---- STATUS
157 ---- STATUS
158 200 Script output follows
158 200 Script output follows
159 ---- HEADERS
159 ---- HEADERS
160 [('Content-Type', 'text/plain; charset=ascii')]
160 [('Content-Type', 'text/plain; charset=ascii')]
161 ---- DATA
161 ---- DATA
162
162
163 /repo/
163 /repo/
164
164
165 ---- ERRORS
165 ---- ERRORS
166
166
167 ---- STATUS
167 ---- STATUS
168 200 Script output follows
168 200 Script output follows
169 ---- HEADERS
169 ---- HEADERS
170 [('Content-Type', 'text/plain; charset=ascii')]
170 [('Content-Type', 'text/plain; charset=ascii')]
171 ---- DATA
171 ---- DATA
172
172
173 -rw-r--r-- 4 bar
173 -rw-r--r-- 4 bar
174
174
175
175
176 ---- ERRORS
176 ---- ERRORS
177
177
178
178
179 $ cd ..
179 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now