:type context: behave.runner.Context
559519
def assert_headers(context):
    
    expected_headers = [(k, v) for k, v in row_table(context).items()]
    request = httpretty.last_request()
    actual_headers = request.headers.items()

    for expected_header in expected_headers:
        assert_in(expected_header, actual_headers)
150973
@SuppressWarnings("unchecked")
    void initThreadContext(WSContextService contextSvc, Map<String, String> execProps) {
        threadContext = contextSvc.captureThreadContext(execProps);
    }
1020310
static final Context context(Element match, int matchIndex, int matchSize) {
        return new DefaultContext(match, matchIndex, matchSize);
    }
39092
def ctx(self):
        '''
        
        '''
        if six.PY2:
            return contextlib.nested(
                self.functions.context_dict.clone(),
                self.returners.context_dict.clone(),
                self.executors.context_dict.clone(),
            )
        else:
            exitstack = contextlib.ExitStack()
            exitstack.enter_context(self.functions.context_dict.clone())
            exitstack.enter_context(self.returners.context_dict.clone())
            exitstack.enter_context(self.executors.context_dict.clone())
            return exitstack
277344
def run_step(context):
    
    logger.debug("started")

    context.clear()
    logger.info(f"Context wiped. New context size: {len(context)}")

    logger.debug("done")
685089
function Context(data, parent, path, env) {
	/** 
	 * Context will inherit of AsyncCollector to manage all internal or external asynchroneous calls.
	 * It allows us to know when a context and its descendants are stabilised(i.e.all data are up to date).
	 **/
	AsyncCollector.call(this);
	this.__yContext__ = true;
	this.data = (data !== undefined) ? data : {};
	this.map = {};
	this.binds = [];
	if (parent) {
		this.parent = parent;
		this.env = env ? new Context(env) : parent.env;
		if (path) {
			var self = this;
			this.path = path;
			this.data = this.data || parent.get(path);
			this.parent.subscribe(path, function(value, type, p, key) {
				// console.log('binded context update : ', type, path, p, key, value);
				if (!p.length)
					p.push('$this');
				switch (type) {
					case 'set':
						self.set(p, value, true);
						break;
					case 'push':
						self.push(p, value, true);
						break;
					case 'delete':
						self.del(p, true);
						break;
					case 'displaceItem':
						self.displaceItem(p, value, true);
						break;
					case 'insertItem':
						self.insertItem(p, value, true);
						break;
					case 'deleteItem':
						self.deleteItem(p, value, true);
						break;
				}
			}, true, this.binds);
		}
	} else
		this.env = env ? (env.__yContext__ ? env : new Env(env)) : Context.env;
}
977140
@Override
    public void run(Context context) throws IOException, InterruptedException {
        outer = context;
        int numberOfThreads = getThreadCount(context);
        mapClass = getMapperClass(context);
        if (LOG.isDebugEnabled()) {
            LOG.debug("Running with " + numberOfThreads + " threads");
        }        
        // current mapper takes 1 thread
        numberOfThreads--;
        
        InputSplit split = context.getInputSplit();

        // submit runners
        try {
	        List<Future<?>> taskList = null;
	        if (threadPool != null) {
            	taskList = new ArrayList<Future<?>>();
                synchronized (threadPool) {
                    for (int i = 0; i < numberOfThreads; ++i) {
                        MapRunner runner = new MapRunner();
                        BaseMapper<K1,V1,K2,V2> mapper = runner.getMapper();
                        if (!threadPool.isShutdown()) {
                            Collection<Future<Object>> tasks = 
                                mapper.submitTasks(threadPool, split);
                            taskList.addAll(tasks);
                            numberOfThreads -= tasks.size();
                            Future<?> future = threadPool.submit(runner);
                            taskList.add(future);	                        
                        } else {
                            throw new InterruptedException(
                                "Thread Pool has been shut down");
                        }
                    }
                    threadPool.notify();
                }
	            
                // MapRunner that runs in current thread
                MapRunner r = new MapRunner();
                r.run();
    
                for (Future<?> f : taskList) {
                    f.get();
                }
	        } else {
	            runners = new ArrayList<MapRunner>(numberOfThreads);
                for (int i = 0; i < numberOfThreads; ++i) {
                    MapRunner thread;
                    thread = new MapRunner();
                    thread.start();
                    runners.add(i, thread);
                }
                // MapRunner runs in current thread
                MapRunner r = new MapRunner();
                r.run();
                
                for (int i = 0; i < numberOfThreads; ++i) {
                    MapRunner thread = runners.get(i);
                    thread.join();
                    Throwable th = thread.throwable;
                    if (th != null) {
                        if (th instanceof IOException) {
                            throw (IOException) th;
                        } else if (th instanceof InterruptedException) {
                            throw (InterruptedException) th;
                        } else {
                            throw new RuntimeException(th);
                        }
                    }
                }
            }       
        } catch (ClassNotFoundException e) {
            LOG.error("MapRunner class not found", e);
        } catch (ExecutionException e) {
        	LOG.error("Error waiting for MapRunner threads to complete", e);
		}        
    }
824513
def getContext(context):
    
    context = aq_parent(aq_base(context))
    if not context or IBrowserView.providedBy(context):
        return getSite()
    return context
827650
def inject_context(self, __context_dict__=None, **context):
        
        context = context or __context_dict__
        self.context_keys |= set(context.keys())
        for key, value in context.items():
            setattr(self, key, value)
        for command in self.subcommands.values():
            command.inject_context(context)
731370
def run(self, context):
        

        args = []
        kwargs = {}
        for arg in self.explicit_arguments:
            if arg.name is not None:
                kwargs[arg.name] = arg.value
            else:
                args.append(arg.value)

        for arg in self.implicit_arguments:
            if arg.name is not None:
                annotation = self.signature.parameters[arg.name].annotation
                annotation_name = annotation
                if not isinstance(annotation, str):
                    annotation_name = annotation.__name__

                if annotation is Table:
                    value = context.table
                elif annotation is Context:
                    value = context
                elif annotation is Text:
                    value = context.text
                elif annotation is inspect._empty:
                    raise RuntimeError(
                        "Parameter '{}' of step implementation '{}{}' does not have a type! Please specify it in the correct steps file.".format(
                            arg.name,
                            self.func.__qualname__,
                            self.signature,

                        )
                    )
                elif CONTEXT_NAMESPACE.format(annotation_name) in context:
                    value = context.__getattr__(CONTEXT_NAMESPACE.format(annotation_name))
                else:
                    raise RuntimeError(
                        "'{}' was not found in context. Is a context parameter missing?".format(arg.name))

                kwargs[arg.name] = value
            else:
                raise RuntimeError("Argument name shouldn't be None")

        with context.user_mode():
            return_value = self.func(*args, **kwargs)
            return_annotation = self.signature.return_annotation
            if return_annotation == inspect.Signature.empty:
                return

            if not isinstance(return_annotation, str):
                return_annotation = return_annotation.__name__

            context.__setattr__(CONTEXT_NAMESPACE.format(return_annotation), return_value)
800291
def set_context(self, definition: Definition, explanation: str) -> None:
        """"""
        self.definition = definition
        self.explanation = explanation
418728
def wrap_context(func):
    
    @functools.wraps(func)
    def wrapper(self, request, context):
        return func(self, request, LogFieldsContext(context))

    return wrapper
621065
function Context(base, args) {
  base = base || process.cwd();
  args = args || {};

  EventEmitter.call(this);

  this.base_dir = base;
  this.log = logger(args);

  this.extend = {
    console: new ConsoleExtend()
  };
}
103624
def create_context(self, message_queue, task_id):
        
        params = (self.settings.dest_directory, self.file_url.json_data, self.seek_amt, self.bytes_to_read)
        return DownloadContext(self.settings, params, message_queue, task_id)
662729
function Context() {
	/**
	 * @member {Object}
	 * @property {Object} client
	 * @property {Object<Call>} client.map - map from call name and call id
	 * @property {Array<Call>} client.list
	 * @property {Object} server
	 * @property {Object<Call>} server.map - map from call name and call id
	 * @property {Array<Call>} server.list
	 * @private
	 */
	this._calls = {
		client: {
			map: Object.create(null),
			list: []
		},
		server: {
			map: Object.create(null),
			list: []
		}
	}

	/**
	 * @member {Object}
	 * @property {Object} client
	 * @property {Object<Message>} client.map - map from message name and message id
	 * @property {Array<Message>} client.list
	 * @property {Object} server
	 * @property {Object<Message>} server.map - map from message name and message id
	 * @property {Array<Message>} server.list
	 * @private
	 */
	this._messages = {
		client: {
			map: Object.create(null),
			list: []
		},
		server: {
			map: Object.create(null),
			list: []
		}
	}
}
1256327
def context(src):
    
    try:
        yield
    except Exception:
        etype, err, tb = sys.exc_info()
        msg = 'An error occurred with source id=%s. Error: %s'
        msg %= (src.source_id, err)
        raise_(etype, msg, tb)
235587
def context_processor(self, func):
        
        func = to_coroutine(func)
        self.providers.append(func)
        return func