Package x2go :: Package tests :: Module runalltests
[frames] | no frames]

Source Code for Module x2go.tests.runalltests

 1  #!/usr/bin/env python 
 2  # -*- coding: utf-8 -*- 
 3   
 4  # Copyright (C) 2010 by Mike Gabriel <mike.gabriel@das-netzwerkteam.de> 
 5  #  
 6  # Python X2go is free software; you can redistribute it and/or modify 
 7  # it under the terms of the GNU General Public License as published by 
 8  # the Free Software Foundation; either version 3 of the License, or 
 9  # (at your option) any later version. 
10  # 
11  # Python X2go is distributed in the hope that it will be useful, 
12  # but WITHOUT ANY WARRANTY; without even the implied warranty of 
13  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
14  # GNU General Public License for more details. 
15  # 
16  # You should have received a copy of the GNU General Public License 
17  # along with this program; if not, write to the 
18  # Free Software Foundation, Inc., 
19  # 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. 
20   
21  """\ 
22  This file is a default test runner as found in ZOPE/Plone products. It works  
23  fine for any kind of Python unit testing---as we do here for Python X2go. 
24  """ 
25   
26  import os 
27  import sys 
28   
29  base = os.path.join(os.path.split(os.path.split(os.getcwd())[0])[0]) 
30   
31  # prepend the X2go path (useful for building new packages) 
32  sys.path = [os.path.normpath(base)] + sys.path 
33   
34  import unittest 
35  TestRunner = unittest.TextTestRunner 
36  suite = unittest.TestSuite() 
37   
38  tests = os.listdir(os.curdir) 
39  tests = [n[:-3] for n in tests if n.startswith('test') and n.endswith('.py')] 
40   
41  for test in tests: 
42      m = __import__(test) 
43      if hasattr(m, 'test_suite'): 
44          suite.addTest(m.test_suite()) 
45   
46  if __name__ == '__main__': 
47      TestRunner().run(suite) 
48