def find_contexts(self, in_request=None, in_resolve=None):
names = self.context_names<EOL>if in_request:<EOL><INDENT>def _in_request(name):<EOL><INDENT>context = self.context(name)<EOL>packages = set(x.name for x in context.requested_packages(True))<EOL>return (in_request in packages)<EOL><DEDENT>names = [x for x in names if _in_request(x)]<EOL><DEDENT>if in_resolve:<EOL><INDENT>if isinstance(in_resolve, str):<EOL><INDENT>in_resolve = PackageRequest(in_resolve)<EOL><DEDENT>def _in_resolve(name):<EOL><INDENT>context = self.context(name)<EOL>variant = context.get_resolved_package(in_resolve.name)<EOL>if variant:<EOL><INDENT>overlap = (variant.version in in_resolve.range)<EOL>return ((in_resolve.conflict and not overlap)<EOL>or (overlap and not in_resolve.conflict))<EOL><DEDENT>else:<EOL><INDENT>return in_resolve.conflict<EOL><DEDENT><DEDENT>names = [x for x in names if _in_resolve(x)]<EOL><DEDENT>return names<EOL>
Find contexts in the suite based on search criteria.

        Args:
            in_request (str): Match contexts that contain the given package in
                their request.
            in_resolve (str or `Requirement`): Match contexts that contain the
                given package in their resolve. You can also supply a conflict
                requirement - '!foo' will match any contexts whos resolve does
                not contain any version of package 'foo'.

        Returns:
            List of context names that match the search criteria.