def test_alwaysPreferPy(self):
        mypath = FilePath(self.mktemp())
        mypath.createDirectory()
        pp = modules.PythonPath(sysPath=[mypath.path])
        originalSmartPath = pp._smartPath
        def _evilSmartPath(pathName):
            o = originalSmartPath(pathName)
            originalChildren = o.children
            def evilChildren():
                # normally this order is random; let's make sure it always
                # comes up .pyc-first.
                x = originalChildren()
                x.sort()
                x.reverse()
                return x
            o.children = evilChildren
            return o
        mypath.child("abcd.py").setContent('\n')
        compileall.compile_dir(mypath.path, quiet=True)
        # sanity check
        self.assertEqual(len(mypath.children()), 2)
        pp._smartPath = _evilSmartPath
        self.assertEqual(pp['abcd'].filePath,
                          mypath.child('abcd.py'))
Verify that .py files will always be preferred to .pyc files, regardless of
dataset/ETHPy150Open nlloyd/SubliminalCollaborator/libs/twisted/test/test_modules.py/BasicTests.test_alwaysPreferPy