regression.py
来自「Dive into Python 中文版」· Python 代码 · 共 35 行
PY
35 行
"""Regression testing frameworkThis module will search for scripts in the same directory namedXYZtest.py. Each such script should be a test suite that tests amodule through PyUnit. (As of Python 2.1, PyUnit is included inthe standard library as 'unittest'.) This script will aggregate allfound test suites into one big test suite and run them all at once.This program is part of "Dive Into Python", a free Python book forexperienced programmers. Visit http://diveintopython.org/ for thelatest version."""__author__ = "Mark Pilgrim (mark@diveintopython.org)"__version__ = "$Revision: 1.4 $"__date__ = "$Date: 2004/05/05 21:57:19 $"__copyright__ = "Copyright (c) 2001 Mark Pilgrim"__license__ = "Python"import sys, os, re, unittestdef regressionTest(): path = os.path.abspath(os.path.dirname(sys.argv[0])) files = os.listdir(path) test = re.compile("test\.py$", re.IGNORECASE) files = filter(test.search, files) filenameToModuleName = lambda f: os.path.splitext(f)[0] moduleNames = map(filenameToModuleName, files) modules = map(__import__, moduleNames) load = unittest.defaultTestLoader.loadTestsFromModule return unittest.TestSuite(map(load, modules))if __name__ == "__main__": unittest.main(defaultTest="regressionTest")
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?