@contextlib.contextmanager<EOL>def _patched_find_module():
if six.PY2:  <EOL><INDENT>def find_module_patched(self, fullname, path=None):<EOL><INDENT>subname = fullname.split("<STR_LIT:.>")[-<NUM_LIT:1>]<EOL>if subname != fullname and self.path is None:<EOL><INDENT>return None<EOL><DEDENT>if self.path is None:<EOL><INDENT>path = None<EOL><DEDENT>else:<EOL><INDENT>path = [self.path]<EOL><DEDENT>try:<EOL><INDENT>file, filename, etc = pkgutil.imp.find_module(subname, path)<EOL><DEDENT>except ImportError:<EOL><INDENT>return None<EOL><DEDENT>return pkgutil.ImpLoader(fullname, file, filename, etc)<EOL><DEDENT>old_find_module = pkgutil.ImpImporter.find_module<EOL>pkgutil.ImpImporter.find_module = find_module_patched<EOL>try:<EOL><INDENT>yield<EOL><DEDENT>finally:<EOL><INDENT>pkgutil.ImpImporter.find_module = old_find_module<EOL><DEDENT><DEDENT>else:<EOL><INDENT>yield<EOL><DEDENT>
Patch bug in pkgutil.ImpImporter.find_module

    When using pkgutil.find_loader on python<3.4 it removes symlinks
    from the path due to a call to os.path.realpath. This is not consistent
    with actually doing the import (in these versions, pkgutil and __import__
    did not share the same underlying code). This can break conftest
    discovery for pytest where symlinks are involved.

    The only supported python<3.4 by pytest is python 2.7.