示例#1
0
文件: test.py 项目: nkhuyu/pyshua
class LeetcodeTest(unittest.TestCase):
    def setUp(self):
        self.judge = Judge()

    def testAllProblems(self):
        leetcodePath = "problems/leetcode/"
        allPyFiles = filter(lambda f: f.endswith(".py"), listdir(leetcodePath))
        pCount = 0
        for f in allPyFiles:
            problemModule = imp.load_source(f[:-3], join(leetcodePath, f))  # filename without .py
            problem = getattr(problemModule, "problem", None)
            if problem:
                self.assertTrue(self.judge.judge(problem()))
                pCount += 1
        print "%i problems verified." % pCount
示例#2
0
class LeetcodeTest(unittest.TestCase):
    def setUp(self):
        self.judge = Judge()

    def testAllProblems(self):
        leetcodePath = 'problems/leetcode/'
        allPyFiles = filter(lambda f: f.endswith('.py'), listdir(leetcodePath))
        pCount = 0
        for f in allPyFiles:
            problemModule = imp.load_source(
                f[:-3],  # filename without .py
                join(leetcodePath, f))
            problem = getattr(problemModule, 'problem', None)
            if problem:
                self.assertTrue(self.judge.judge(problem()))
                pCount += 1
        print '%i problems verified.' % pCount