SyFi
0.3
|
Functions | |
def | discover_packages |
def | discover_tests |
def | run_suite |
def | main |
Variables | |
string | __author__ = "Martin Alnes (martinal@simula.no) and Anders Logg (logg@simula.no)" |
string | __date__ = "2008-03-12 -- 2011-04-08" |
def test.discover_packages | ( | ) |
Definition at line 11 of file test.py.
Referenced by main().
00011 00012 def discover_packages(): 00013 # Looking at tests in all test_foo/ packages 00014 packages = sorted(f for f in glob.glob("test_*") 00015 if os.path.exists(os.path.join(f,'__init__.py'))) 00016 return packages
def test.discover_tests | ( | p | ) |
Definition at line 17 of file test.py.
Referenced by main().
00017 00018 def discover_tests(p): 00019 import glob, os 00020 # Running tests from all test_foo.py files in each package 00021 tests = sorted(os.path.basename(f.replace(".py", "")) 00022 for f in glob.glob(os.path.join(p,"test_*.py"))) 00023 return tests
def test.main | ( | args | ) |
Definition at line 35 of file test.py.
References discover_packages(), discover_tests(), and run_suite().
00035 00036 def main(args): 00037 s, f = 0, 0 00038 cwd = os.path.abspath(os.curdir) 00039 00040 tfilter = [] 00041 for a in args: 00042 if a.startswith('test_'): 00043 tfilter.append(a) 00044 else: 00045 print "Ignoring argument", a 00046 if tfilter: 00047 print "Running only tests", tfilter 00048 00049 packages = discover_packages() 00050 for p in packages: 00051 tests = discover_tests(p) 00052 if tfilter: 00053 # Use only tests found in args 00054 tests = [t for t in tests if t in tfilter] 00055 if not tests: 00056 continue 00057 result = run_suite(p, tests) 00058 os.chdir(cwd) # In case tests mess up current directory... 00059 if result.wasSuccessful(): 00060 s += 1 00061 else: 00062 f += 1 00063 00064 if not f: 00065 print "All tests finished successfully." 00066 return 0 00067 else: 00068 print "Not all tests finished successfully." 00069 return 1
def test.run_suite | ( | package, | |
tests | |||
) |
Definition at line 24 of file test.py.
Referenced by main().
00024 00025 def run_suite(package, tests): 00026 assert tests 00027 loader = unittest.TestLoader() 00028 p = __import__(package, fromlist=tests) 00029 modules = [getattr(p,test) for test in tests] 00030 suite = loader.loadTestsFromModule(modules[0]) 00031 for m in modules[1:]: 00032 suite.addTests(loader.loadTestsFromModule(m)) 00033 runner = unittest.TextTestRunner(verbosity=2) 00034 return runner.run(suite)
string test::__author__ = "Martin Alnes (martinal@simula.no) and Anders Logg (logg@simula.no)" |
string test::__date__ = "2008-03-12 -- 2011-04-08" |