Ejemplo n.º 1
0
 def setUp(self):
     en.enable(callback=exc_handler_ret)
Ejemplo n.º 2
0
 def setUp(self):
     en.enable(callback=exc_handler_ret, both=True)
Ejemplo n.º 3
0
It turns out that both cgitb.handler and exception_notifier.mail_exception does
not terminate the program after handling exception. This is a violation of
default Python behavior.

Since nov. 30, 2013
"""

import sys
sys.path.insert(0, '..')

import exception_notifier as en
import cgitb

cgitb.enable()


def f():
    1 / 0


if __name__ == '__main__':
    en.enable()
    f()
    en.disable()

    try:
        f()
    except:
        cgitb.handler()
    print("After an exception is caught, should this show up?")
Ejemplo n.º 4
0
 def setUp(self):
     en.enable()
Ejemplo n.º 5
0
"""
Script for manual tests.

Since nov. 28, 2013
"""

import sys
sys.path.insert(0, '..')

import exception_notifier as en


def div(x, y):
    return x / y


def cb():
    return 'E'

g = en.mail_exception()(div)

if __name__ == '__main__':
    # test decorator
    g(1, 0)

    # test enable
    en.enable(callback=cb, both=True)
    # XXX: Cannot get return value of callback in exception hook.
    print(div(1, 0))
    en.disable()