Module TestAll
[hide private]
[frames] | no frames]

Source Code for Module TestAll

 1  #!/usr/bin/python 
 2  ##################################################################### 
 3  # -*- coding: iso-8859-1 -*-                                        # 
 4  #                                                                   # 
 5  # Frets on Fire                                                     # 
 6  # Copyright (C) 2006 Sami Kyöstilä                                  # 
 7  #                                                                   # 
 8  # This program is free software; you can redistribute it and/or     # 
 9  # modify it under the terms of the GNU General Public License       # 
10  # as published by the Free Software Foundation; either version 2    # 
11  # of the License, or (at your option) any later version.            # 
12  #                                                                   # 
13  # This program is distributed in the hope that it will be useful,   # 
14  # but WITHOUT ANY WARRANTY; without even the implied warranty of    # 
15  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the     # 
16  # GNU General Public License for more details.                      # 
17  #                                                                   # 
18  # You should have received a copy of the GNU General Public License # 
19  # along with this program; if not, write to the Free Software       # 
20  # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,        # 
21  # MA  02110-1301, USA.                                              # 
22  ##################################################################### 
23   
24  """Run all unit tests.""" 
25   
26  import sys 
27  import os 
28  import unittest 
29   
30  tests = [] 
31   
32  for root, dirs, files in os.walk("."): 
33    for f in files: 
34      f = os.path.join(root, f) 
35      if f.endswith("Test.py"): 
36        m = os.path.basename(f).replace(".py", "") 
37        d = os.path.dirname(f) 
38        sys.path.append(d) 
39        tests.append(__import__(m)) 
40   
41  suite = unittest.TestSuite() 
42   
43  if "-i" in sys.argv: 
44    suffix = "TestInteractive" 
45  else: 
46    suffix = "Test" 
47   
48  for test in tests: 
49    for item in dir(test): 
50      if item.endswith(suffix): 
51        suite.addTest(unittest.makeSuite(test.__dict__[item])) 
52     
53  unittest.TextTestRunner(verbosity = 2).run(suite) 
54