def import_plugin(self, modname, consider_entry_points=False):
<EOL>assert isinstance(modname, six.string_types), (<EOL>"<STR_LIT>" % modname<EOL>)<EOL>modname = str(modname)<EOL>if self.is_blocked(modname) or self.get_plugin(modname) is not None:<EOL><INDENT>return<EOL><DEDENT>importspec = "<STR_LIT>" + modname if modname in builtin_plugins else modname<EOL>self.rewrite_hook.mark_rewrite(importspec)<EOL>if consider_entry_points:<EOL><INDENT>loaded = self.load_setuptools_entrypoints("<STR_LIT>", name=modname)<EOL>if loaded:<EOL><INDENT>return<EOL><DEDENT><DEDENT>try:<EOL><INDENT>__import__(importspec)<EOL><DEDENT>except ImportError as e:<EOL><INDENT>new_exc_message = '<STR_LIT>' % (<EOL>modname,<EOL>safe_str(e.args[<NUM_LIT:0>]),<EOL>)<EOL>new_exc = ImportError(new_exc_message)<EOL>tb = sys.exc_info()[<NUM_LIT:2>]<EOL>six.reraise(ImportError, new_exc, tb)<EOL><DEDENT>except Skipped as e:<EOL><INDENT>from _pytest.warnings import _issue_warning_captured<EOL>_issue_warning_captured(<EOL>PytestWarning("<STR_LIT>" % (modname, e.msg)),<EOL>self.hook,<EOL>stacklevel=<NUM_LIT:1>,<EOL>)<EOL><DEDENT>else:<EOL><INDENT>mod = sys.modules[importspec]<EOL>self.register(mod, modname)<EOL><DEDENT>
Imports a plugin with ``modname``. If ``consider_entry_points`` is True, entry point
names are also considered to find a plugin.