'Ensure we can collect files with weird file extensions as Python
modules (#2369)'

def test_issue2369_collect_module_fileext(self, testdir):

    testdir.makeconftest('\n                                                import    sys,    os,    imp\n                                                from    _pytest.python    import    Module\n\n                                                class    Loader:\n                                                                def    load_module(self,    name):\n                                                                                return    imp.load_source(name,    name    +    ".narf")\n                                                class    Finder:\n                                                                def    find_module(self,    name,    path=None):\n                                                                                if    os.path.exists(name    +    ".narf"):\n                                                                                                return    Loader()\n                                                sys.meta_path.append(Finder())\n\n                                                def    pytest_collect_file(path,    parent):\n                                                                if    path.ext    ==    ".narf":\n                                                                                return    Module(path,    parent)')
    testdir.makefile('.narf', '\n                                                def    test_something():\n                                                                assert    1    +    1    ==    2')
    result = testdir.runpytest_subprocess()
    result.stdout.fnmatch_lines('*1    passed*')
