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
 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
 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)
 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)
 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)
 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')
 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
 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
 def when_i_poll_the_function(self):
     self.exception = catch(poll_,
                            self.function_to_poll,
                            lambda x: x == 1,
                            interval=0.001)
示例#18
0
 def when_i_execute_the_retryable_function(self):
     self.exception = catch(self.function_to_retry)
 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
 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
 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
 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
 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)
 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)
 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)
 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,
                                     {})
 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)
 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
 def when_I_set_the_handler(self):
     self.exception = contexts.catch(self.channel.set_return_handler, "i am not callable")
示例#44
0
 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
 def because_the_bad_frame_arrives(self):
     self.exception = contexts.catch(self.server.send_bytes, self.raw)
 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
 def when_i_retry_the_function(self):
     self.exception = catch(retry_, self.function_to_retry, [ValueError, IndexError], times=3, interval=0.001)
示例#49
0
 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
 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
 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
 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
 def because_we_read_the_table(self, bytes):
     self.exception = contexts.catch(serialisation.read_table, BytesIO(bytes))
 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()
 def when_we_try_to_use_the_decorators(self):
     self.exception = catch(self.throwing_func)