tests/hgweberror.py
changeset 43076 2372284d9457
parent 40155 0199fb5dde20
child 48875 6000f5b25c9b
equal deleted inserted replaced
43075:57875cf423c9 43076:2372284d9457
     1 # A dummy extension that installs an hgweb command that throws an Exception.
     1 # A dummy extension that installs an hgweb command that throws an Exception.
     2 
     2 
     3 from __future__ import absolute_import
     3 from __future__ import absolute_import
     4 
     4 
     5 from mercurial.hgweb import (
     5 from mercurial.hgweb import webcommands
     6     webcommands,
     6 
     7 )
       
     8 
     7 
     9 def raiseerror(web):
     8 def raiseerror(web):
    10     '''Dummy web command that raises an uncaught Exception.'''
     9     '''Dummy web command that raises an uncaught Exception.'''
    11 
    10 
    12     # Simulate an error after partial response.
    11     # Simulate an error after partial response.
    17         list(web.res.sendresponse())
    16         list(web.res.sendresponse())
    18         web.res.getbodyfile().write(b'partial content\n')
    17         web.res.getbodyfile().write(b'partial content\n')
    19 
    18 
    20     raise AttributeError('I am an uncaught error!')
    19     raise AttributeError('I am an uncaught error!')
    21 
    20 
       
    21 
    22 def extsetup(ui):
    22 def extsetup(ui):
    23     setattr(webcommands, 'raiseerror', raiseerror)
    23     setattr(webcommands, 'raiseerror', raiseerror)
    24     webcommands.__all__.append(b'raiseerror')
    24     webcommands.__all__.append(b'raiseerror')