used for __mock_dispatch
175827
def __mock_failed msg, actual_args, disps=__mock_disps[msg]
      if expected = __mock_find_checked_difi(disps, actual_args)
        Mock.__send__(:raise, # Too many times
          Expected.new(object, expected, disps.size, disps.size+1))
      else
        Mock.__send__(:raise, # Wrong argument
          Unexpected.new(object, disps, msg, actual_args))
      end
    end
743598
def _dispatch(self, tree):
        ""
        if isinstance(tree, list):
            for t in tree:
                self._dispatch(t)
            return
        meth = getattr(self, "_"+tree.__class__.__name__)
        if tree.__class__.__name__ == 'NoneType' and not self._do_indent:
            return
        meth(tree)
75194
function echoMock(mock, echo) {
            mockService.update({'identifier': mock.identifier, 'echo': echo}, function () {
                vm.echos[mock.identifier] = echo;
            });
        }
1118918
def dispatch_hook(cls, _pkt=None, *args, **kargs):
        

        if _pkt:
            attr_type = orb(_pkt[0])
            return cls.registered_attributes.get(attr_type, cls)
        return cls
1189400
function Dispatcher() {
  let lastId = 1;
  let prefix = "ID_";
  let callbacks = {};
  let isPending = {};
  let isHandled = {};
  let isDispatching = false;
  let pendingPayload = null;

  function invokeCallback(id) {
    isPending[id] = true;
    callbacks[id](pendingPayload);
    isHandled[id] = true;
  }

  this.register = callback => {
    let id = prefix + lastId++;
    callbacks[id] = callback;
    return id;
  };

  this.unregister = id => {
    if (!callbacks.hasOwnProperty(id))
      return new Error("Cannot unregister unknown ID!");
    delete callbacks[id];
    return id;
  };

  this.waitFor = ids => {
    for (var i = 0; i < ids.length; i++) {
      var id = ids[id];
      if (isPending[id]) {
        return new Error("Circular dependency waiting for " + id);
      }

      if (!callbacks[id]) {
        return new Error(`waitFor: ${id} is not a registered callback.`);
      }

      invokeCallback(id);
    }

    return undefined;
  };

  this.dispatch = payload => {
    if (isDispatching) return new Error("Cannot dispatch while dispatching.");

    // start
    for (var id in callbacks) {
      isPending[id] = false;
      isHandled[id] = false;
    }

    pendingPayload = payload;
    isDispatching = true;

    // run each callback.
    try {
      for (var id in callbacks) {
        if (isPending[id]) continue;
        invokeCallback(id);
      }
    } finally {
      pendingPayload = null;
      isDispatching = false;
    }

    return payload;
  };
}
1340569
def _Function(self, t):
        
        if t.decorators is not None:
            self._fill("@")
            self._dispatch(t.decorators)
        self._fill("def "+t.name + "(")
        defaults = [None] * (len(t.argnames) - len(t.defaults)) + list(t.defaults)
        for i, arg in enumerate(zip(t.argnames, defaults)):
            self._write(arg[0])
            if arg[1] is not None:
                self._write('=')
                self._dispatch(arg[1])
            if i < len(t.argnames)-1:
                self._write(', ')
        self._write(")")
        if self._single_func:
            self._do_indent = False
        self._enter()
        self._dispatch(t.code)
        self._leave()
        self._do_indent = True
556753
function mockPlugin(name, deferInit = false) {
        class MockPlugin {
            constructor(params, ws) {
                this.ws = ws;
                // using the instance factory unfortunately makes it
                // difficult to use the spyOn function, so we use this
                // instead
                this.isInitialised = false;
            }
            init() {
                this.isInitialised = true;
            }
            destroy() {}
        }
        return {
            name,
            deferInit,
            staticProps: {
                [`${name}Static`]: 'static property value'
            },
            instance: MockPlugin
        };
    }
264142
def mock_attr(self, *args, **kwargs):
        
        self.path.extend(args)
        self.qs.update(kwargs)
        return self
530452
def dispatch(self, request, *args, **kwargs):
        
        self.args = args
        self.kwargs = kwargs
        request = self.initialize_request(request, *args, **kwargs)
        self.request = request
        self.headers = self.default_response_headers  # deprecate?

        try:
            self.initial(request, *args, **kwargs)

            # Get the appropriate handler method
            if request.method.lower() in self.http_method_names:
                handler = getattr(self, request.method.lower(),
                                  self.http_method_not_allowed)
            else:
                handler = self.http_method_not_allowed

            response = handler(request, *args, **kwargs)

        except Exception as exc:
            response = self.handle_exception(exc)

        self.response = self.finalize_response(request, response, *args, **kwargs)
        return self.response
1125941
def __mock_block_call context, block, actual_args, actual_block, splat
      return unless block
      # for AnyInstanceOf, we don't have the actual context at the time
      # we're defining it, so we update it here
      block.context = context if block.kind_of?(Block)
      if splat
        block.call(*actual_args, &actual_block)
      else # peek_return doesn't need splat
        block.call(actual_args, &actual_block)
      end
    end
733956
def mock(self, obj=None, attr=None, **kwargs):
        '''
        
        '''
        rval = Mock(**kwargs)
        if obj is not None and attr is not None:
            rval._object = obj
            rval._attr = attr

            if hasattr(obj, attr):
                orig = getattr(obj, attr)
                self._mocks.append((obj, attr, orig))
                setattr(obj, attr, rval)
            else:
                self._mocks.append((obj, attr))
                setattr(obj, attr, rval)
        return rval
445518
function mock () {
    // flag set if any library is successfully mocked
    var mocked = false

    // attempt to load mockable libraries
    _.each(automock.module, (module, name) => {
        // catch errors on libraries that are not available
        try {
            // load library to be mocked
            var library = require(module.libraryName)
            // apply automock function on library
            library.automock(module.automock)
            // set success flag
            mocked = true
        }
        catch (ex) {
            console.log(ex)
        }
    })

    // throw error if no libraries found
    if (!mocked) {
        throw new Error('immutable-automock: no mockable libraries found')
    }

    // return class instance for chaining
    return automock
}
47234
def dispatch(self, tree):
        ""
        if isinstance(tree, list):
            for t in tree:
                self.dispatch(t)
            return
        meth = getattr(self, "_" + tree.__class__.__name__)
        meth(tree)
758832
function mock (mock) {
  if (mock === false) {
    mocking = false
  } else {
    mocking = true
    cli.stderr = ''
    cli.stdout = ''
  }
}
448958
function mockImplementation (req, res, next) {
    if (res.swagger) {
      // Determine the semantics of this request
      let request = new SemanticRequest(req);

      // Determine which mock to run
      let mock;
      if (request.isCollection) {
        mock = queryCollection[req.method] || editCollection[req.method];
      }
      else {
        mock = queryResource[req.method] || editResource[req.method];
      }

      // Get the current DataStore (this can be changed at any time by third-party code)
      let db = util.isExpressApp(router) ? router.get("mock data store") || dataStore : dataStore;
      db.__router = router;

      // Run the mock
      util.debug("Running the %s mock", mock.name);
      mock(req, res, next, db);
    }
    else {
      next();
    }
  }
458646
function MockRes (url, cb) {
    this.url = url;
    this.headers = {};
    this.content = undefined;
    this.setHeader = function (name, value) {
        this.headers[name] = value;
    }.bind(this);
    this.end = function (content) {
        this.content = content;
        cb(this);
    }.bind(this);
}
253820
def _class_dispatch(args, kwargs):
    """"""
    _ = kwargs
    if not args:
        raise ValueError(
            "Multimethods must be passed at least one positional arg.")

    if not isinstance(args[0], type):
        raise TypeError(
            "class_multimethod must be called with a type, not instance.")

    return args[0]