Ejemplo n.º 1
0

def main(argv):
    global called_main_function_name
    called_main_function_name = 'main'

    real_main(argv)


if __name__ == '__main__':
    use_custom_main = os.environ.get('APP_TEST_USE_CUSTOM_MAIN', False)
    if use_custom_main:
        main_func = custom_main
    else:
        main_func = main
    custom_argv = os.environ.get('APP_TEST_CUSTOM_ARGV', None)
    if custom_argv:
        custom_argv = custom_argv.split(' ')
    else:
        custom_argv = None

    app.install_exception_handler(MyExceptionHandler('first'))
    app.install_exception_handler(MyExceptionHandler('second'))
    app.run(main=main_func, argv=custom_argv)

    if main_func:
        if called_main_function_name != 'custom_main':
            print('called_main_function_name should be custom_main, found %s.',
                  called_main_function_name)
            sys.exit(1)
Ejemplo n.º 2
0
 def test_install_exception_handler(self):
     with self.assertRaises(TypeError):
         app.install_exception_handler(1)