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