def test_nonDirectoryPaths(self): """ Verify that L{modules.walkModules} ignores entries in sys.path which refer to regular files in the filesystem. """ existentPath = self.pathEntryWithOnePackage() nonDirectoryPath = FilePath(self.mktemp()) self.failIf(nonDirectoryPath.exists()) nonDirectoryPath.setContent("zip file or whatever\n") self.replaceSysPath([existentPath.path]) beforeModules = list(modules.walkModules()) sys.path.append(nonDirectoryPath.path) afterModules = list(modules.walkModules()) self.assertEquals(beforeModules, afterModules)
def test_nonexistentPaths(self): """ Verify that L{modules.walkModules} ignores entries in sys.path which do not exist in the filesystem. """ existentPath = self.pathEntryWithOnePackage() nonexistentPath = FilePath(self.mktemp()) self.failIf(nonexistentPath.exists()) self.replaceSysPath([existentPath.path]) expected = [modules.getModule("test_package")] beforeModules = list(modules.walkModules()) sys.path.append(nonexistentPath.path) afterModules = list(modules.walkModules()) self.assertEquals(beforeModules, expected) self.assertEquals(afterModules, expected)