Package sabayon :: Module unittests
[hide private]
[frames] | no frames]

Source Code for Module sabayon.unittests

 1  #!/usr/bin/env python 
 2   
 3  # 
 4  # Copyright (C) 2005 Red Hat, Inc. 
 5  # 
 6  # This program 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 2 of the License, or 
 9  # (at your option) any later version. 
10  # 
11  # This program 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 Free Software 
18  # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 
19  # 
20   
21  import sys 
22  import util 
23  import pygtk; pygtk.require("2.0") 
24   
25  if __name__ == "__main__": 
26      util.init_gettext () 
27       
28 - def add_mod_dir ():
29 sys.path.append ("sources")
30 - def remove_mod_dir ():
31 sys.path.remove ("sources")
32 33 unit_tests = [ 34 ( "storage", None, None, None ), 35 ( "util", None, None, None ), 36 ( "dirmonitor", None, None, None ), 37 ( "filessource", None, add_mod_dir, remove_mod_dir ), 38 ( "gconfsource", _("Ignore WARNINGs"), add_mod_dir, remove_mod_dir ), 39 ( "paneldelegate", _("Ignore WARNINGs"), add_mod_dir, remove_mod_dir ), 40 ( "mozillasource", None, add_mod_dir, remove_mod_dir ), 41 ( "userprofile", None, None, None ), 42 ( "systemdb", None, None, None ), 43 ( "cache", None, None, None ) 44 ] 45 46 if len (sys.argv) > 1: 47 tests_to_run = sys.argv[1:] 48 else: 49 tests_to_run = [] 50 for test in unit_tests: 51 tests_to_run.append (test[0]) 52
53 - def run_unit_tests (module):
54 cmd = ("import %s\n%s.run_unit_tests ()") % (module, module) 55 exec (cmd)
56 57 for (module, msg, pre_func, post_func) in unit_tests: 58 if not module in tests_to_run: 59 continue 60 if not msg: 61 print _("Running %s tests") % module 62 else: 63 print _("Running %s tests (%s)") % (module, msg) 64 if pre_func: 65 pre_func () 66 run_unit_tests (module) 67 if post_func: 68 post_func () 69 70 print _("Success!") 71