Пример #1
0
    def test_failure_on_construction_fails_as_expected(self, mock_service):

        ex = eager_tf_executor.EagerTFExecutor()
        ex_factory = executor_stacks.ResourceManagingExecutorFactory(
            lambda _: ex)

        with self.assertRaises(ValueError):
            with server_utils.server_context(ex_factory, 1,
                                             portpicker.pick_unused_port()):
                time.sleep(1)
Пример #2
0
    def test_server_context_shuts_down_uncaught_exception(
            self, mock_logging_info):

        ex = eager_tf_executor.EagerTFExecutor()

        with self.assertRaises(TypeError):
            with server_utils.server_context(
                    ex, 1, portpicker.pick_unused_port()) as server:
                time.sleep(1)
                raise TypeError

        mock_logging_info.assert_called_once_with('Shutting down server.')
Пример #3
0
    def test_server_context_shuts_down_uncaught_exception(
            self, mock_logging_info):

        ex = eager_tf_executor.EagerTFExecutor()
        ex_factory = executor_stacks.ResourceManagingExecutorFactory(
            lambda _: ex)

        with self.assertRaises(TypeError):
            with server_utils.server_context(
                    ex_factory, 1, portpicker.pick_unused_port()) as server:
                time.sleep(1)
                raise TypeError

        mock_logging_info.assert_called_once_with('Shutting down server.')
Пример #4
0
    def test_server_context_shuts_down_under_keyboard_interrupt(
            self, mock_logging_info):

        ex = eager_tf_executor.EagerTFExecutor()

        with server_utils.server_context(
                ex, 1, portpicker.pick_unused_port()) as server:
            time.sleep(1)
            raise KeyboardInterrupt

        mock_logging_info.assert_has_calls([
            mock.call('Server stopped by KeyboardInterrupt.'),
            mock.call('Shutting down server.')
        ])