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
Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 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
Esempio n. 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)
Esempio n. 12
0
 def because_the_bad_frame_arrives(self):
     self.exception = contexts.catch(self.protocol.data_received, self.raw)
Esempio n. 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)
Esempio n. 15
0
 def because_we_call_catch(self):
     self.caught = contexts.catch(self.throwing_function, 3, c='yes', b=None)
Esempio n. 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))
Esempio n. 17
0
 def when_i_poll_the_function(self):
     self.exception = catch(poll_,
                            self.function_to_poll,
                            lambda x: x == 1,
                            interval=0.001)
Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 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))
Esempio n. 23
0
 def when_we_wait_for_the_timeout_and_retry(self):
     self.exception = contexts.catch(self.function_to_break)
Esempio n. 24
0
 def when_i_override_a_nonexistent_property(self):
     self.exception = catch(lambda name: getattr(self.builder, name),
                            'with_nonexistent')
Esempio n. 25
0
 def when_i_call_the_circuit_breaker_function(self):
     self.exception = contexts.catch(self.function_to_break)
Esempio n. 26
0
 def when_i_execute_the_function_to_poll(self):
     self.exception = catch(self.function_to_poll)
Esempio n. 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)
Esempio n. 28
0
 def when_I_set_the_handler(self):
     self.exception = contexts.catch(self.channel.set_return_handler, "i am not callable")
Esempio n. 29
0
 def when_i_execute_the_retryable_function(self):
     self.exception = catch(self.function_to_retry)
Esempio n. 30
0
 def because_the_framework_asks_the_plugin_to_identify_the_method(
         self, method):
     self.exception = contexts.catch(self.identifier.identify_method,
                                     method)
Esempio n. 31
0
 def when_i_retry_the_function(self):
     self.exception = catch(retry_,
                            self.function_to_retry,
                            [ValueError, IndexError],
                            times=3,
                            interval=0.001)
Esempio n. 32
0
 def because_the_bad_frame_arrives(self):
     self.exception = contexts.catch(self.server.send_bytes, self.raw)
Esempio n. 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)
Esempio n. 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)
Esempio n. 38
0
 def because_we_call_catch(self):
     self.caught = contexts.catch(self.throwing_function,
                                  3,
                                  c='yes',
                                  b=None)
Esempio n. 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)
Esempio n. 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)
Esempio n. 43
0
 def when_I_set_the_handler(self):
     self.exception = contexts.catch(self.channel.set_return_handler, "i am not callable")
Esempio n. 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))
Esempio n. 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())
Esempio n. 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))
Esempio n. 48
0
 def when_i_retry_the_function(self):
     self.exception = catch(retry_, self.function_to_retry, [ValueError, IndexError], times=3, interval=0.001)
Esempio n. 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)
Esempio n. 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)
Esempio n. 51
0
 def because_we_read_the_table(self, bytes):
     self.exception = contexts.catch(serialisation.read_table,
                                     BytesIO(bytes))
Esempio n. 52
0
 def when_i_poll_the_function(self):
     self.exception = catch(poll_,
                            self.function_to_poll,
                            lambda self: self.throw(),
                            interval=0.001)
Esempio n. 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
Esempio n. 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
Esempio n. 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)
Esempio n. 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, {})
Esempio n. 58
0
 def when_the_connection_dies(self):
     contexts.catch(self.protocol.connection_lost, self.exception)
     self.tick()
Esempio n. 59
0
 def when_we_try_to_use_the_decorators(self):
     self.exception = catch(self.throwing_func)