Inspected function should be called exactly number times
        Return: self
777700
def exactly(self, number):
        
        def check(): #pylint: disable=missing-docstring
            return True if number == super(SinonExpectation, self).callCount else False
        self.valid_list.append(check)
        return self
976385
def initialize_check_thread(self, check_func):
        # type: (_MultiprocessOffload, function) -> None
        
        self._check_thread = threading.Thread(target=check_func)
        self._check_thread.start()
1233718
def _callable_once(func):
    

    def once(*args, **kwargs):
        if not once.called:
            once.called = True
            return func(*args, **kwargs)

    once.called = False
    return once
696200
def trace_inspect(self):
        
        def decorator(f):
            self.tracer.inspector = f
            return f
        return decorator
1129811
def _Verify(self):
    

    # If the list of expected calls is not empty, raise an exception
    if self._expected_calls_queue:
      # The last MultipleTimesGroup is not popped from the queue.
      if (len(self._expected_calls_queue) == 1 and
          isinstance(self._expected_calls_queue[0], MultipleTimesGroup) and
          self._expected_calls_queue[0].IsSatisfied()):
        pass
      else:
        raise ExpectedMethodCallsError(self._expected_calls_queue)
622970
def repeat_all(self, count=2):
        
        try:
            return self.__class__(''.join(str(self) * count))
        except TypeError:
            raise TypeError(
                '`count` must be an integer. Got: {!r}'.format(count)
            )
780077
def _ensure_5args(func):
    
    if func is None:
        return None

    self_arg = 1 if inspect.ismethod(func) else 0
    if len(inspect.getargspec(func)[0]) == 5 + self_arg:
        return func
    if len(inspect.getargspec(func)[0]) == 4 + self_arg:
        return lambda t, y, J, dfdt, fy=None: func(t, y, J, dfdt)
    else:
        raise ValueError("Incorrect numer of arguments")
975397
def log_every_x_times(logger, counter, x, msg, *args, **kwargs):
    '''
    
    '''
    if counter==1 or counter % x == 0:
        #msg = msg + (' (counter %i)' % counter)
        logdebug(logger, msg, *args, **kwargs)
679672
def _every(times, step_size, index):
        
        current = index * step_size
        step = current // times * times
        reached = current >= step
        overshot = current >= step + step_size
        return current and reached and not overshot
1332600
def init_check(self, check, obj):
        
        self.logger.info('Adding extension check %s' % check.__name__)
        check = functools.wraps(check)(functools.partial(check, obj))
        self.check(func=check)
460546
def _repeat(func):
    """"""
    @functools.wraps(func)
    def wrapper(*args, **kwargs):
        """Repeats the call until True is returned."""
        ret = None
        while ret is None:
            ret = func(*args, **kwargs)
        return ret
    return wrapper
1363585
def observed(cls, _func):
        

        def wrapper(*args, **kwargs):
            self = args[0]
            assert(isinstance(self, Observable))

            self._notify_method_before(self, _func.__name__, args, kwargs)
            res = _func(*args, **kwargs)
            self._notify_method_after(self, _func.__name__, res, args, kwargs)
            return res

        return wrapper
179441
def run(self):
        '''
        
        '''
        tests = self._collect()

        if not tests:
            return

        self.times
        self.before_class()

        for test in tests:
            func = getattr(self, test)
            results = self.results[test] = Result()
            self._before(self, test)
            self.before()
            for i in range(self.times):
                self._before_each(self, test, i)
                result = self._run_one(func)
                results.total += result.duration
                if result.success:
                    results.has_success = True
                else:
                    results.has_errors = True
                self._after_each(self, test, i)
                if self.debug and not result.success:
                    results.error = result.result
                    break
            self.after()
            self._after(self, test)

        self.after_class()
1325410
def check(func):
    
    def iCheck(request, *args, **kwargs):
        if not request.method == "POST":
            return HttpResponseBadRequest("Must be POST request.")
        follow = func(request, *args, **kwargs)
        if request.is_ajax():
            return HttpResponse('ok')
        try:
            if 'next' in request.GET:
                return HttpResponseRedirect(request.GET.get('next'))
            if 'next' in request.POST:
                return HttpResponseRedirect(request.POST.get('next'))
            return HttpResponseRedirect(follow.target.get_absolute_url())
        except (AttributeError, TypeError):
            if 'HTTP_REFERER' in request.META:
                return HttpResponseRedirect(request.META.get('HTTP_REFERER', '/'))
            if follow:
                return HttpResponseServerError('"%s" object of type ``%s`` has no method ``get_absolute_url()``.' % (
                    unicode(follow.target), follow.target.__class__))
            return HttpResponseServerError('No follow object and `next` parameter found.')
    return iCheck
459593
def assure_check(fnc):
    
    @wraps(fnc)
    def _wrapped(self, check, *args, **kwargs):
        if not isinstance(check, CloudMonitorCheck):
            # Must be the ID
            check = self._check_manager.get(check)
        return fnc(self, check, *args, **kwargs)
    return _wrapped
510166
def times( &action )
      i = @function.variable INT, 'i'
      @function << "#{@function.indent}for ( #{i} = 0; " +
                   "#{i} != #{self}; #{i}++ ) {\n"
      @function.indent_offset +1
      action.call i
      @function.indent_offset -1
      @function << "#{@function.indent}};\n"
      self
    end
649190
def once(self, event: str, *handlers: T.Callable) -> T.Callable:
        """"""

        def _once_wrapper(*handlers: T.Callable) -> T.Callable:
            """Wrapper for 'once' decorator"""

            def _wrapper(*args: T.Any, **kw: T.Any) -> None:
                """Wrapper that unregisters itself before executing
                the handlers"""

                self.off(event, _wrapper)
                for handler in handlers:
                    handler(*args, **kw)

            return _wrapper

        if handlers:
            return self.on(event, _once_wrapper(*handlers))
        return lambda x: self.on(event, _once_wrapper(x))