def _call_waiting_msg(self): call_wait = self.__expectation__.pop(0) if call_wait.attribute == "__call__": attribute = self.__last_property_called__ else: attribute = call_wait.attribute return "Call waiting: %s" % format_called(attribute, call_wait.args, call_wait.kargs)
def _unexpected_call_msg(self, attr, args, kargs): if attr == "__call__": attribute = self.__last_property_called__ else: attribute = attr return "Mock Object received unexpected call:%s" % format_called( attribute, args, kargs)
def _unexpected_call_msg(self, attr, args, kargs): return ("Mock Object received unexpected call:%s\n" "Expected:\n" "%s\n" "Got:\n" "%s") % (format_called(attr, args, kargs), self.__traceroute_expected__.stack_code(), self.__traceroute__.stack_trace())
def _unexpected_call_msg(self, attr, args, kargs): return ("Mock Object received unexpected call:%s\n" "Expected:\n" "%s\n" "Got:\n" "%s") % ( format_called(attr, args, kargs), self.__traceroute_expected__.stack_code(), self.__traceroute__.stack_trace())
def called(self, times): called_count = self.spy.called_count( [self._attr_called, self.args, self.kargs]) if not times.verify(called_count): raise SpyExpectationError( "Spy expected %s %s%d times but received %d" % (format_called(self._attr_called, self.args, self.kargs), times.operator_message, times.expectation_value, called_count))
def called(self, times): called_count = self.spy.called_count([self._attr_called, self.args, self.kargs]) if not times.verify(called_count): raise SpyExpectationError("Spy expected %s %s%d times but received %d" % ( format_called(self._attr_called, self.args, self.kargs), times.operator_message, times.expectation_value, called_count))
def _unexpected_call_msg(self, attr, args, kargs): if attr == "__call__": attribute = self.__last_property_called__ else: attribute = attr return "Mock Object received unexpected call:%s" % format_called(attribute, args, kargs)
def _format_called(self, attr, args, kargs): if attr == '__call__' and self.__last_property_called__: attr = self.__last_property_called__ return format_called(attr, args, kargs)
def compare(self): if not self.calls.index(self.before) > self.calls.index(self.after): raise SpyExpectationError( "Spy expected %s called after %s" % (format_called(*self.before), format_called(*self.after)))
def compare(self): if not self.calls.index(self.before) > self.calls.index(self.after): raise SpyExpectationError("Spy expected %s called after %s" % (format_called(*self.before), format_called(*self.after)))