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