Пример #1
0
    def test_framework_hooks(self):
        app = self.make_app(APP, argv=['--quiet'])
        app.hook.register('pre_setup', cement_hook_one)
        app.hook.register('post_setup', cement_hook_one)
        app.hook.register('pre_run', cement_hook_one)
        app.hook.register('post_run', cement_hook_one)
        app.hook.register('pre_argument_parsing', cement_hook_one)
        app.hook.register('post_argument_parsing', cement_hook_one)
        app.hook.register('pre_close', cement_hook_one)
        app.hook.register('post_close', cement_hook_one)
        app.hook.register('signal', cement_hook_one)
        app.hook.register('pre_render', cement_hook_one)
        app.hook.register('pre_render', cement_hook_five)
        app.hook.register('post_render', cement_hook_one)
        app.hook.register('post_render', cement_hook_five)
        app.setup()
        app.run()
        app.render(dict(foo='bar'))
        app.close()

        # this is where cement_signal_hook is run
        try:
            frame = sys._getframe(0)
            foundation.cement_signal_handler(signal.SIGTERM, frame)
        except exc.CaughtSignal as e:
            pass
Пример #2
0
    def test_framework_hooks(self):
        app = self.make_app(APP, argv=['--quiet'])
        app.hook.register('pre_setup', cement_hook_one)
        app.hook.register('post_setup', cement_hook_one)
        app.hook.register('pre_run', cement_hook_one)
        app.hook.register('post_run', cement_hook_one)
        app.hook.register('pre_argument_parsing', cement_hook_one)
        app.hook.register('post_argument_parsing', cement_hook_one)
        app.hook.register('pre_close', cement_hook_one)
        app.hook.register('post_close', cement_hook_one)
        app.hook.register('signal', cement_hook_one)
        app.hook.register('pre_render', cement_hook_one)
        app.hook.register('pre_render', cement_hook_five)
        app.hook.register('post_render', cement_hook_one)
        app.hook.register('post_render', cement_hook_five)
        app.setup()
        app.run()
        app.render(dict(foo='bar'))
        app.close()

        # this is where cement_signal_hook is run
        try:
            frame = sys._getframe(0)
            foundation.cement_signal_handler(signal.SIGTERM, frame)
        except exc.CaughtSignal as e:
            pass
Пример #3
0
    def test_framework_hooks(self):
        app = self.make_app(APP, argv=["--quiet"])
        hook.register("pre_setup", cement_hook_one)
        hook.register("post_setup", cement_hook_one)
        hook.register("pre_run", cement_hook_one)
        hook.register("post_run", cement_hook_one)
        hook.register("pre_argument_parsing", cement_hook_one)
        hook.register("post_argument_parsing", cement_hook_one)
        hook.register("pre_close", cement_hook_one)
        hook.register("post_close", cement_hook_one)
        hook.register("signal", cement_hook_one)
        hook.register("pre_render", cement_hook_one)
        hook.register("pre_render", cement_hook_five)
        hook.register("post_render", cement_hook_one)
        hook.register("post_render", cement_hook_five)
        app.setup()
        app.run()
        app.render(dict(foo="bar"))
        app.close()

        # this is where cement_signal_hook is run
        try:
            foundation.cement_signal_handler(signal.SIGTERM, 5)
        except exc.CaughtSignal as e:
            pass
Пример #4
0
def test_cement_signal_handler():
    # coverage
    with pytest.raises(CaughtSignal):
        mframe = Mock()
        mframe.f_globals.values = MagicMock(return_value=[TestApp()])
        cement_signal_handler(1, mframe)
        mframe.f_globals.values.assert_called()
Пример #5
0
 def test_cement_signal_handler(self):
     import signal
     try:
         foundation.cement_signal_handler(signal.SIGTERM, 5)
     except exc.CaughtSignal as e:
         self.eq(e.signum, signal.SIGTERM)
         self.eq(e.frame, 5)
         raise
Пример #6
0
 def test_cement_signal_handler(self):
     import signal
     try:
         foundation.cement_signal_handler(signal.SIGTERM, 5)
     except exc.CaughtSignal as e:
         self.eq(e.signum, signal.SIGTERM)
         self.eq(e.frame, 5)
         raise
Пример #7
0
 def test_cement_signal_handler(self):
     import signal
     import types
     global app
     app = self.make_app('test')
     frame = sys._getframe(0)
     try:
         foundation.cement_signal_handler(signal.SIGTERM, frame)
     except exc.CaughtSignal as e:
         self.eq(e.signum, signal.SIGTERM)
         self.ok(isinstance(e.frame, types.FrameType))
         raise
Пример #8
0
 def test_cement_signal_handler(self):
     import signal
     import types
     global app
     app = self.make_app('test')
     frame = sys._getframe(0)
     try:
         foundation.cement_signal_handler(signal.SIGTERM, frame)
     except exc.CaughtSignal as e:
         self.eq(e.signum, signal.SIGTERM)
         self.ok(isinstance(e.frame, types.FrameType))
         raise