Mercurial > hg
annotate tests/hgweberror.py @ 35074:62e10bf001a9
test-pattern: actually update tests using the patterns
We mass update the tests now. This will help the next soul touching the http
protocol.
author | Boris Feld <boris.feld@octobus.net> |
---|---|
date | Sun, 05 Nov 2017 08:23:12 +0100 |
parents | 74e6de99ce7f |
children | 3d60a22e27f5 |
rev | line source |
---|---|
23409
dc4d2cd3aa3e
hgweb: send proper HTTP response after uncaught exception
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1 # A dummy extension that installs an hgweb command that throws an Exception. |
dc4d2cd3aa3e
hgweb: send proper HTTP response after uncaught exception
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
2 |
27299
74e6de99ce7f
tests: use absolute_import in hgweberror.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
23409
diff
changeset
|
3 from __future__ import absolute_import |
74e6de99ce7f
tests: use absolute_import in hgweberror.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
23409
diff
changeset
|
4 |
74e6de99ce7f
tests: use absolute_import in hgweberror.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
23409
diff
changeset
|
5 from mercurial.hgweb import ( |
74e6de99ce7f
tests: use absolute_import in hgweberror.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
23409
diff
changeset
|
6 webcommands, |
74e6de99ce7f
tests: use absolute_import in hgweberror.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
23409
diff
changeset
|
7 ) |
23409
dc4d2cd3aa3e
hgweb: send proper HTTP response after uncaught exception
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
8 |
dc4d2cd3aa3e
hgweb: send proper HTTP response after uncaught exception
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
9 def raiseerror(web, req, tmpl): |
dc4d2cd3aa3e
hgweb: send proper HTTP response after uncaught exception
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
10 '''Dummy web command that raises an uncaught Exception.''' |
dc4d2cd3aa3e
hgweb: send proper HTTP response after uncaught exception
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
11 |
dc4d2cd3aa3e
hgweb: send proper HTTP response after uncaught exception
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
12 # Simulate an error after partial response. |
dc4d2cd3aa3e
hgweb: send proper HTTP response after uncaught exception
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
13 if 'partialresponse' in req.form: |
dc4d2cd3aa3e
hgweb: send proper HTTP response after uncaught exception
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
14 req.respond(200, 'text/plain') |
dc4d2cd3aa3e
hgweb: send proper HTTP response after uncaught exception
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
15 req.write('partial content\n') |
dc4d2cd3aa3e
hgweb: send proper HTTP response after uncaught exception
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
16 |
dc4d2cd3aa3e
hgweb: send proper HTTP response after uncaught exception
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
17 raise AttributeError('I am an uncaught error!') |
dc4d2cd3aa3e
hgweb: send proper HTTP response after uncaught exception
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
18 |
dc4d2cd3aa3e
hgweb: send proper HTTP response after uncaught exception
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
19 def extsetup(ui): |
dc4d2cd3aa3e
hgweb: send proper HTTP response after uncaught exception
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
20 setattr(webcommands, 'raiseerror', raiseerror) |
dc4d2cd3aa3e
hgweb: send proper HTTP response after uncaught exception
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
21 webcommands.__all__.append('raiseerror') |