def importorskip(modname, minversion=None, reason=None):
import warnings<EOL>__tracebackhide__ = True<EOL>compile(modname, "<STR_LIT>", "<STR_LIT>")  <EOL>should_skip = False<EOL>with warnings.catch_warnings():<EOL><INDENT>warnings.simplefilter("<STR_LIT:ignore>")<EOL>try:<EOL><INDENT>__import__(modname)<EOL><DEDENT>except ImportError:<EOL><INDENT>should_skip = True<EOL><DEDENT><DEDENT>if should_skip:<EOL><INDENT>if reason is None:<EOL><INDENT>reason = "<STR_LIT>" % (modname,)<EOL><DEDENT>raise Skipped(reason, allow_module_level=True)<EOL><DEDENT>mod = sys.modules[modname]<EOL>if minversion is None:<EOL><INDENT>return mod<EOL><DEDENT>verattr = getattr(mod, "<STR_LIT>", None)<EOL>if minversion is not None:<EOL><INDENT>try:<EOL><INDENT>from pkg_resources import parse_version as pv<EOL><DEDENT>except ImportError:<EOL><INDENT>raise Skipped(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>" % (modname,),<EOL>allow_module_level=True,<EOL>)<EOL><DEDENT>if verattr is None or pv(verattr) < pv(minversion):<EOL><INDENT>raise Skipped(<EOL>"<STR_LIT>"<EOL>% (modname, verattr, minversion),<EOL>allow_module_level=True,<EOL>)<EOL><DEDENT><DEDENT>return mod<EOL>
Imports and returns the requested module ``modname``, or skip the current test
    if the module cannot be imported.

    :param str modname: the name of the module to import
    :param str minversion: if given, the imported module ``__version__`` attribute must be
        at least this minimal version, otherwise the test is still skipped.
    :param str reason: if given, this reason is shown as the message when the module
        cannot be imported.