コード例 #1
0
 def given_the_circuit_was_about_to_be_broken(self):
     self.patch = mock.patch('time.perf_counter', return_value=0)
     self.mock = self.patch.start()
     contexts.catch(self.function_to_break)
     self.mock.return_value = 0.5
     contexts.catch(self.function_to_break)
     self.mock.return_value = 1.1
コード例 #2
0
 def given_the_circuit_was_about_to_be_broken(self):
     self.patch = mock.patch('time.perf_counter', return_value=0)
     self.mock = self.patch.start()
     contexts.catch(self.function_to_break)
     self.mock.return_value = 0.5
     contexts.catch(self.function_to_break)
     self.mock.return_value = 1.1
コード例 #3
0
 def given_the_circuit_was_half_broken_and_the_function_failed_again(self):
     self.x = 0
     self.patch = mock.patch('time.perf_counter', return_value=0)
     self.mock = self.patch.start()
     contexts.catch(self.function_to_break)
     contexts.catch(self.function_to_break)
     contexts.catch(self.function_to_break)
     self.mock.return_value = 1.1
     contexts.catch(self.function_to_break)
コード例 #4
0
 def given_the_circuit_was_half_broken_and_the_function_failed_again(self):
     self.x = 0
     self.patch = mock.patch('time.perf_counter', return_value=0)
     self.mock = self.patch.start()
     contexts.catch(self.function_to_break)
     contexts.catch(self.function_to_break)
     contexts.catch(self.function_to_break)
     self.mock.return_value = 1.1
     contexts.catch(self.function_to_break)
コード例 #5
0
 def given_the_function_has_failed_three_times(self):
     self.patch = mock.patch('time.perf_counter', return_value=0)
     self.mock = self.patch.start()
     self.x = 0
     contexts.catch(self.function_to_break)
     contexts.catch(self.function_to_break)
     contexts.catch(self.function_to_break)
     self.x = 0
コード例 #6
0
 def given_the_circuit_was_broken_in_the_past(self):
     self.x = 0
     self.expected_exception = ValueError()
     self.patch = mock.patch('time.perf_counter', return_value=0)
     self.mock = self.patch.start()
     contexts.catch(self.function_to_break)
     contexts.catch(self.function_to_break)
     contexts.catch(self.function_to_break)
コード例 #7
0
 def given_the_circuit_was_broken_in_the_past(self):
     self.x = 0
     self.expected_exception = ValueError()
     self.patch = mock.patch('time.perf_counter', return_value=0)
     self.mock = self.patch.start()
     contexts.catch(self.function_to_break)
     contexts.catch(self.function_to_break)
     contexts.catch(self.function_to_break)
コード例 #8
0
 def given_the_circuit_was_broken_in_the_past(self):
     self.x = 0
     self.expected_return_value = "some thing that was returned"
     self.patch = mock.patch('time.perf_counter', return_value=0)
     self.mock = self.patch.start()
     contexts.catch(self.function_to_break)
     contexts.catch(self.function_to_break)
     contexts.catch(self.function_to_break)
コード例 #9
0
 def given_the_function_has_failed_three_times(self):
     self.patch = mock.patch('time.perf_counter', return_value=0)
     self.mock = self.patch.start()
     self.x = 0
     contexts.catch(self.function_to_break)
     contexts.catch(self.function_to_break)
     contexts.catch(self.function_to_break)
     self.x = 0
コード例 #10
0
 def given_the_circuit_was_broken_in_the_past(self):
     self.x = 0
     self.expected_return_value = "some thing that was returned"
     self.patch = mock.patch('time.perf_counter', return_value=0)
     self.mock = self.patch.start()
     contexts.catch(self.function_to_break)
     contexts.catch(self.function_to_break)
     contexts.catch(self.function_to_break)
コード例 #11
0
 def when_i_call_the_circuit_breaker_function(self):
     self.exception = contexts.catch(self.function_to_break)
コード例 #12
0
 def because_the_bad_frame_arrives(self):
     self.exception = contexts.catch(self.protocol.data_received, self.raw)
コード例 #13
0
 def when_i_override_a_nonexistent_property(self):
     self.exception = catch(lambda name: getattr(self.builder, name), 'with_nonexistent')
コード例 #14
0
 def when_we_import_the_module_and_prompt_it_to_raise_the_exception(self):
     self.module = self.importer.import_module(TEST_DATA_DIR, self.module_name)
     self.exc = contexts.catch(self.module.assertion_func)
コード例 #15
0
 def because_we_call_catch(self):
     self.caught = contexts.catch(self.throwing_function, 3, c='yes', b=None)
コード例 #16
0
ファイル: serialisation_tests.py プロジェクト: helgim/asynqp
 def because_we_read_the_table(self, bytes):
     # We expect the serialisation to read over the bounds, but only if it is unsigned
     self.exception = contexts.catch(serialisation.read_table, BytesIO(bytes))
コード例 #17
0
ファイル: poll_tests.py プロジェクト: arunchandarQA/poll
 def when_i_poll_the_function(self):
     self.exception = catch(poll_,
                            self.function_to_poll,
                            lambda x: x == 1,
                            interval=0.001)
コード例 #18
0
ファイル: retry_tests.py プロジェクト: benjamin-hodgson/poll
 def when_i_execute_the_retryable_function(self):
     self.exception = catch(self.function_to_retry)
コード例 #19
0
 def when_the_call_fails_again(self):
     self.exception = contexts.catch(self.function_to_break)
コード例 #20
0
 def when_we_run_the_function_again(self):
     self.exception1 = contexts.catch(self.function_to_break)
     self.exception2 = contexts.catch(self.function_to_break)
     self.exception3 = contexts.catch(self.function_to_break)
コード例 #21
0
 def when_i_call_the_circuit_breaker_function(self):
     self.mock.return_value = 0.5
     self.exception = contexts.catch(self.function_to_break)
コード例 #22
0
ファイル: integration_tests.py プロジェクト: mosquito/asynqp
 def when_I_cancel_the_consumer_and_also_get_a_message(self):
     self.consumer.cancel()
     self.exception = contexts.catch(self.loop.run_until_complete, asyncio.wait_for(self.queue.get(), 0.2))
コード例 #23
0
 def when_we_wait_for_the_timeout_and_retry(self):
     self.exception = contexts.catch(self.function_to_break)
コード例 #24
0
ファイル: builder_tests.py プロジェクト: WEPjockey/build
 def when_i_override_a_nonexistent_property(self):
     self.exception = catch(lambda name: getattr(self.builder, name),
                            'with_nonexistent')
コード例 #25
0
 def when_i_call_the_circuit_breaker_function(self):
     self.exception = contexts.catch(self.function_to_break)
コード例 #26
0
ファイル: poll_tests.py プロジェクト: arunchandarQA/poll
 def when_i_execute_the_function_to_poll(self):
     self.exception = catch(self.function_to_poll)
コード例 #27
0
 def given_the_function_has_failed_twice(self):
     self.expected_exception = ValueError()
     contexts.catch(self.function_to_break)
     contexts.catch(self.function_to_break)
コード例 #28
0
ファイル: channel_tests.py プロジェクト: urbaniak/asynqp
 def when_I_set_the_handler(self):
     self.exception = contexts.catch(self.channel.set_return_handler, "i am not callable")
コード例 #29
0
 def when_i_execute_the_retryable_function(self):
     self.exception = catch(self.function_to_retry)
コード例 #30
0
 def because_the_framework_asks_the_plugin_to_identify_the_method(
         self, method):
     self.exception = contexts.catch(self.identifier.identify_method,
                                     method)
コード例 #31
0
 def when_i_retry_the_function(self):
     self.exception = catch(retry_,
                            self.function_to_retry,
                            [ValueError, IndexError],
                            times=3,
                            interval=0.001)
コード例 #32
0
 def because_the_bad_frame_arrives(self):
     self.exception = contexts.catch(self.server.send_bytes, self.raw)
コード例 #33
0
 def it_should_raise_error_in_connection_methods(self):
     exc = contexts.catch(self.wait_for, self.connection.open_channel())
     assert isinstance(exc, exceptions.ConnectionClosed)
コード例 #34
0
 def when_i_call_the_circuit_breaker_function(self):
     self.mock.return_value = 0.5
     self.exception = contexts.catch(self.function_to_break)
コード例 #35
0
 def when_we_import_the_module_and_prompt_it_to_raise_the_exception(self):
     self.module = self.importer.import_module(TEST_DATA_DIR,
                                               self.module_name)
     self.exc = contexts.catch(self.module.assertion_func)
コード例 #36
0
 def when_we_run_the_function_again(self):
     self.exception1 = contexts.catch(self.function_to_break)
     self.exception2 = contexts.catch(self.function_to_break)
     self.exception3 = contexts.catch(self.function_to_break)
コード例 #37
0
 def because_the_framework_asks_the_plugin_to_identify_the_method(self, method):
     self.exception = contexts.catch(self.identifier.identify_method, method)
コード例 #38
0
 def because_we_call_catch(self):
     self.caught = contexts.catch(self.throwing_function,
                                  3,
                                  c='yes',
                                  b=None)
コード例 #39
0
 def because_we_try_to_initialise_the_plugin(self):
     self.exception = contexts.catch(self.supplier.initialise, self.args,
                                     {})
コード例 #40
0
 def when_we_wait_for_the_timeout_and_retry(self):
     self.exception = contexts.catch(self.function_to_break)
コード例 #41
0
 def when_we_try_to_use_the_decorators(self):
     self.exception = catch(self.throwing_func)
コード例 #42
0
 def given_the_function_has_failed_twice(self):
     self.expected_exception = ValueError()
     contexts.catch(self.function_to_break)
     contexts.catch(self.function_to_break)
コード例 #43
0
ファイル: channel_tests.py プロジェクト: georgwaechter/asynqp
 def when_I_set_the_handler(self):
     self.exception = contexts.catch(self.channel.set_return_handler, "i am not callable")
コード例 #44
0
ファイル: integration_tests.py プロジェクト: txomon/asynqp
 def when_I_cancel_the_consumer_and_also_get_a_message(self):
     self.consumer.cancel()
     self.exception = contexts.catch(
         self.loop.run_until_complete,
         asyncio.wait_for(self.queue.get(), 0.2))
コード例 #45
0
ファイル: protocol_tests.py プロジェクト: TarasLevelUp/asynqp
 def because_the_bad_frame_arrives(self):
     self.exception = contexts.catch(self.server.send_bytes, self.raw)
コード例 #46
0
 def because_an_unexpected_error_occurs(self):
     self.exception = contexts.catch(self.before.unexpected_error, Exception())
コード例 #47
0
 def because_we_read_the_table(self, bytes):
     # We expect the serialisation to read over the bounds, but only if it is unsigned
     self.exception = contexts.catch(serialisation.read_table, BytesIO(bytes))
コード例 #48
0
ファイル: retry_tests.py プロジェクト: benjamin-hodgson/poll
 def when_i_retry_the_function(self):
     self.exception = catch(retry_, self.function_to_retry, [ValueError, IndexError], times=3, interval=0.001)
コード例 #49
0
ファイル: connection_tests.py プロジェクト: mosquito/asynqp
 def it_should_raise_error_in_connection_methods(self):
     exc = contexts.catch(self.wait_for, self.connection.open_channel())
     assert isinstance(exc, exceptions.AlreadyClosed)
コード例 #50
0
ファイル: poll_tests.py プロジェクト: arunchandarQA/poll
 def when_i_poll_the_function(self):
     self.exception = catch(poll_,
                            self.function_to_poll,
                            lambda x: x == 3,
                            timeout=0.04,
                            interval=0.03)
コード例 #51
0
 def because_we_read_the_table(self, bytes):
     self.exception = contexts.catch(serialisation.read_table,
                                     BytesIO(bytes))
コード例 #52
0
ファイル: poll_tests.py プロジェクト: arunchandarQA/poll
 def when_i_poll_the_function(self):
     self.exception = catch(poll_,
                            self.function_to_poll,
                            lambda self: self.throw(),
                            interval=0.001)
コード例 #53
0
 def because_we_read_a_bad_long_string(self):
     self.exception = contexts.catch(
         serialisation.read_long_string,
         BytesIO(b"\x00\x00\x00\x10hello"))  # length too long
コード例 #54
0
ファイル: serialisation_tests.py プロジェクト: helgim/asynqp
 def because_we_read_a_bad_long_string(self):
     self.exception = contexts.catch(
         serialisation.read_long_string, BytesIO(b"\x00\x00\x00\x10hello")
     )  # length too long
コード例 #55
0
 def because_we_try_to_import_the_file(self):
     self.exception = contexts.catch(self.importer.import_module, TEST_DATA_DIR, self.module_name)
コード例 #56
0
ファイル: serialisation_tests.py プロジェクト: helgim/asynqp
 def because_we_read_the_table(self, bytes):
     self.exception = contexts.catch(serialisation.read_table, BytesIO(bytes))
コード例 #57
0
 def because_we_try_to_initialise_the_plugin(self):
     self.exception = contexts.catch(self.supplier.initialise, self.args, {})
コード例 #58
0
 def when_the_connection_dies(self):
     contexts.catch(self.protocol.connection_lost, self.exception)
     self.tick()
コード例 #59
0
 def when_we_try_to_use_the_decorators(self):
     self.exception = catch(self.throwing_func)