Wrapper to create a function for negating spy methods
488582
function(fn) {
        // Save off the existing spy method as __functionName
        var newName = '__' + fn;
        self[newName] = self[fn];

        // This is the actual function that will be called when,
        // for example, calledWith() is invoked
        return function() {
          var func = self[newName];
          
          // If this thing is a function, invoke it with all arguments;
          // otherwise, just grab the value of the property.
          var val = typeof func === 'function' ? func.apply(condition, arguments) : func;

          // Negate and return
          return !val;
        };
      }
390840
function tryCatch(fnc, context, args) {

		try {
			// Start execusting the function
			switch (args.length) {
				// Avoid apply for up to 3 arguments
				case 1:
					fnc.call(context, args[0]);
					break;
				case 2:
					fnc.call(context, args[0], args[1]);
					break;
				case 3:
					fnc.call(context, args[0], args[1], args[2]);
					break;
				case 4:
					fnc.call(context, args[0], args[1], args[2], args[3]);
					break;
				// Use the slower apply
				default:
					fnc.apply(context, args);
			}
		} catch (err) {
			return err;
		}

		return null;
	}
1297652
public static <R, T> Function<T, R> spyRes(Function<T, R> function, Box<R> result) {
        return spy(function, result, Box.<T>empty());
    }
787035
def calledWithMatch(cls, spy, *args, **kwargs): #pylint: disable=invalid-name
        
        cls.__is_spy(spy)
        if not (spy.calledWithMatch(*args, **kwargs)):
            raise cls.failException(cls.message)
884107
public static function spy()
    {
        if (! static::isMock()) {
            $class = static::getMockableClass();

            return tap($class ? Mockery::spy($class) : Mockery::spy(), function ($spy) {
                static::swap($spy);
            });
        }
    }
822596
function nthCallWith(spy, n, expArgs) {
    if (spy.calls.length < n) return false;

    var actArgs = spy.calls[n].slice()
      , passed = 0;

    expArgs.forEach(function (expArg) {
      for (var i = 0; i < actArgs.length; i++) {
        if (_.eql(actArgs[i], expArg)) {
          passed++;
          actArgs.splice(i, 1);
          break;
        }
      }
    });

    return passed === expArgs.length
  }
1027877
function SpyConstructor (opts) {
    Constructor.call(this, opts)

    // Spy on Constructor functions
    for (var key in this) {
      if (this[key] instanceof Function) {
        this[key] = sinon.spy(this[key])
      }
    }

    SpyConstructor.instances.push(this)
  }
105538
def handler(self):
		''
		from feedjack import filters # shouldn't be imported globally, as they may depend on models
		proc_func = getattr(filters, self.handler_name or self.name, None)
		if proc_func is None:
			if '.' not in self.handler_name:
				raise ImportError('Processing function not available: {0}'.format(self.handler_name))
			proc_module, proc_func = it.imap(str, self.handler_name.rsplit('.', 1))
			proc_func = getattr(__import__(proc_module, fromlist=[proc_func]), proc_func)
		return proc_func
1195415
def _handler(func):
    ""

    def _wrapped(*a, **k):
        r = func(*a, **k)
        if r is None: r = 0
        return r

    return staticmethod(_wrapped)
1367145
def calledThrice(cls, spy): #pylint: disable=invalid-name
        
        cls.__is_spy(spy)
        if not (spy.calledThrice):
            raise cls.failException(cls.message)
529803
def alwaysCalledWithMatch(cls, spy, *args, **kwargs): #pylint: disable=invalid-name
        
        cls.__is_spy(spy)
        if not (spy.alwaysCalledWithMatch(*args, **kwargs)):
            raise cls.failException(cls.message)
379200
def untrace_function(module, function):
    

    if not is_traced(function):
        return False

    name = get_object_name(function)
    setattr(module, name, untracer(function))
    return True
587408
def no_login_required(func):
    
    @functools.wraps(func)
    def decorated_view(*args, **kwargs):
        return func(*args, **kwargs)
    return decorated_view
646944
function makeEventTarget(target) {
    var listeners = {};
    target.on = function(event, func) {
      if (listeners[event]) {
        listeners[event].push(func);
      } else {
        listeners[event] = [func];
      }
    };
    target.fireEvent = function(event, data) {
      expect(target.on).toHaveBeenCalledWith(event, jasmine.any(Function));
      listeners[event].forEach(function(listener) {
        listener(data);
      });
    };
    target.removeListeners = function() {
      listeners = {};
    };
    spyOn(target, "on").and.callThrough();
  }
344668
def is_intercepted(target):
    

    result = False

    # get interception function from input target
    function = _get_function(target)

    result = hasattr(function, _INTERCEPTED)

    return result
696200
def trace_inspect(self):
        
        def decorator(f):
            self.tracer.inspector = f
            return f
        return decorator
293470
function Expect (condition) {
  var self = this;
  Indeed.apply(this, arguments);
  this.calls = ['expect'];

  // Duck-typing: condition is a sinon spy
  if (condition && condition.displayName && condition.args && condition.calledWith) {
    // Extend expect with spy assertions
    _.extend(this, condition);

    // We need to change the functionality of "not" for spies, because
    // expect(spy).not.to.have.been.called doesn't act as expected otherwise.
    this.__defineGetter__('not', function() {
      // Still set this flag in case, by some chance,
      // a build in method is called instead
      self.flags.not = true;

      // Wrapper to create a function for negating spy methods
      var createFunc = function(fn) {
        // Save off the existing spy method as __functionName
        var newName = '__' + fn;
        self[newName] = self[fn];

        // This is the actual function that will be called when,
        // for example, calledWith() is invoked
        return function() {
          var func = self[newName];
          
          // If this thing is a function, invoke it with all arguments;
          // otherwise, just grab the value of the property.
          var val = typeof func === 'function' ? func.apply(condition, arguments) : func;

          // Negate and return
          return !val;
        };
      };

      // Thought about saving a literal list of spy functions to replace,
      // but I don't want this lib to be dependent on a particular version
      // of sinon. So instead, we're just doing them all, which should be safe
      // since this only happens when "not" is called. But . . . it would
      // be weird to do expect(spy).not.to.yieldTo(/*...*/) or such.
      for (var fn in condition) {
        if (condition.hasOwnProperty(fn)) {
          // Keep the API the same as sinon. If this thing is a function,
          // replace it with a function. If it's a property, replace it with
          // a getter, so that every can be used exactly the same way.
          if (typeof condition[fn] === 'function') {
            self[fn] = createFunc(fn);
          } else {
            self.__defineGetter__(fn, createFunc(fn));
          }
        }
      }

      // For chaining purposes.
      return this;
    });
  }
}