##// END OF EJS Templates
py3: add b'' prefixes in tests/test-hgweb-no-path-info.t...
Pulkit Goyal -
r39695:19f70138 default
parent child Browse files
Show More
@@ -1,146 +1,146
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 > 'PATH_INFO': '/',
50 > 'PATH_INFO': '/',
51 > 'SCRIPT_NAME': '',
51 > 'SCRIPT_NAME': '',
52 > 'SERVER_NAME': '$LOCALIP',
52 > 'SERVER_NAME': '$LOCALIP',
53 > 'SERVER_PORT': os.environ['HGPORT'],
53 > 'SERVER_PORT': os.environ['HGPORT'],
54 > 'SERVER_PROTOCOL': 'HTTP/1.0'
54 > 'SERVER_PROTOCOL': 'HTTP/1.0'
55 > }
55 > }
56 >
56 >
57 > def process(app):
57 > def process(app):
58 > content = app(env, startrsp)
58 > content = app(env, startrsp)
59 > sys.stdout.write(output.getvalue())
59 > sys.stdout.write(output.getvalue())
60 > sys.stdout.write(''.join(content))
60 > sys.stdout.write(''.join(content))
61 > getattr(content, 'close', lambda : None)()
61 > getattr(content, 'close', lambda : None)()
62 > print('---- ERRORS')
62 > print('---- ERRORS')
63 > print(errors.getvalue())
63 > print(errors.getvalue())
64 >
64 >
65 > output = stringio()
65 > output = stringio()
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['QUERY_STRING'] = 'style=raw'
70 > env['QUERY_STRING'] = 'style=raw'
71 > process(hgwebdir({'repo': '.'}))
71 > process(hgwebdir({'repo': b'.'}))
72 > EOF
72 > EOF
73 $ $PYTHON request.py
73 $ $PYTHON request.py
74 ---- STATUS
74 ---- STATUS
75 200 Script output follows
75 200 Script output follows
76 ---- HEADERS
76 ---- HEADERS
77 [('Content-Type', 'application/atom+xml; charset=ascii')]
77 [('Content-Type', 'application/atom+xml; charset=ascii')]
78 ---- DATA
78 ---- DATA
79 <?xml version="1.0" encoding="ascii"?>
79 <?xml version="1.0" encoding="ascii"?>
80 <feed xmlns="http://www.w3.org/2005/Atom">
80 <feed xmlns="http://www.w3.org/2005/Atom">
81 <!-- Changelog -->
81 <!-- Changelog -->
82 <id>http://$LOCALIP:$HGPORT/</id> (glob)
82 <id>http://$LOCALIP:$HGPORT/</id> (glob)
83 <link rel="self" href="http://$LOCALIP:$HGPORT/atom-log"/> (glob)
83 <link rel="self" href="http://$LOCALIP:$HGPORT/atom-log"/> (glob)
84 <link rel="alternate" href="http://$LOCALIP:$HGPORT/"/> (glob)
84 <link rel="alternate" href="http://$LOCALIP:$HGPORT/"/> (glob)
85 <title>repo Changelog</title>
85 <title>repo Changelog</title>
86 <updated>1970-01-01T00:00:00+00:00</updated>
86 <updated>1970-01-01T00:00:00+00:00</updated>
87
87
88 <entry>
88 <entry>
89 <title>[default] test</title>
89 <title>[default] test</title>
90 <id>http://$LOCALIP:$HGPORT/#changeset-61c9426e69fef294feed5e2bbfc97d39944a5b1c</id> (glob)
90 <id>http://$LOCALIP:$HGPORT/#changeset-61c9426e69fef294feed5e2bbfc97d39944a5b1c</id> (glob)
91 <link href="http://$LOCALIP:$HGPORT/rev/61c9426e69fe"/> (glob)
91 <link href="http://$LOCALIP:$HGPORT/rev/61c9426e69fe"/> (glob)
92 <author>
92 <author>
93 <name>test</name>
93 <name>test</name>
94 <email>&#116;&#101;&#115;&#116;</email>
94 <email>&#116;&#101;&#115;&#116;</email>
95 </author>
95 </author>
96 <updated>1970-01-01T00:00:00+00:00</updated>
96 <updated>1970-01-01T00:00:00+00:00</updated>
97 <published>1970-01-01T00:00:00+00:00</published>
97 <published>1970-01-01T00:00:00+00:00</published>
98 <content type="xhtml">
98 <content type="xhtml">
99 <table xmlns="http://www.w3.org/1999/xhtml">
99 <table xmlns="http://www.w3.org/1999/xhtml">
100 <tr>
100 <tr>
101 <th style="text-align:left;">changeset</th>
101 <th style="text-align:left;">changeset</th>
102 <td>61c9426e69fe</td>
102 <td>61c9426e69fe</td>
103 </tr>
103 </tr>
104 <tr>
104 <tr>
105 <th style="text-align:left;">branch</th>
105 <th style="text-align:left;">branch</th>
106 <td>default</td>
106 <td>default</td>
107 </tr>
107 </tr>
108 <tr>
108 <tr>
109 <th style="text-align:left;">bookmark</th>
109 <th style="text-align:left;">bookmark</th>
110 <td></td>
110 <td></td>
111 </tr>
111 </tr>
112 <tr>
112 <tr>
113 <th style="text-align:left;">tag</th>
113 <th style="text-align:left;">tag</th>
114 <td>tip</td>
114 <td>tip</td>
115 </tr>
115 </tr>
116 <tr>
116 <tr>
117 <th style="text-align:left;">user</th>
117 <th style="text-align:left;">user</th>
118 <td>&#116;&#101;&#115;&#116;</td>
118 <td>&#116;&#101;&#115;&#116;</td>
119 </tr>
119 </tr>
120 <tr>
120 <tr>
121 <th style="text-align:left;vertical-align:top;">description</th>
121 <th style="text-align:left;vertical-align:top;">description</th>
122 <td>test</td>
122 <td>test</td>
123 </tr>
123 </tr>
124 <tr>
124 <tr>
125 <th style="text-align:left;vertical-align:top;">files</th>
125 <th style="text-align:left;vertical-align:top;">files</th>
126 <td>bar<br /></td>
126 <td>bar<br /></td>
127 </tr>
127 </tr>
128 </table>
128 </table>
129 </content>
129 </content>
130 </entry>
130 </entry>
131
131
132 </feed>
132 </feed>
133 ---- ERRORS
133 ---- ERRORS
134
134
135 ---- STATUS
135 ---- STATUS
136 200 Script output follows
136 200 Script output follows
137 ---- HEADERS
137 ---- HEADERS
138 [('Content-Type', 'text/plain; charset=ascii')]
138 [('Content-Type', 'text/plain; charset=ascii')]
139 ---- DATA
139 ---- DATA
140
140
141 /repo/
141 /repo/
142
142
143 ---- ERRORS
143 ---- ERRORS
144
144
145
145
146 $ cd ..
146 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now