Slicer 4.2
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
testing.py
Go to the documentation of this file.
00001 
00002 #
00003 # Testing
00004 #
00005 
00006 from slicer.util import EXIT_FAILURE, EXIT_SUCCESS
00007 
00008 _status = EXIT_FAILURE
00009 
00010 def enabled():
00011   from slicer import app
00012   return app.testingEnabled()
00013   
00014 def setEnabled():
00015   from slicer import app
00016   app.setTestingEnabled()
00017   
00018 def exitSuccess():
00019   global _status
00020   _status = EXIT_SUCCESS
00021 
00022 def exitFailure(message = ""):
00023   global _status
00024   _status = EXIT_FAILURE
00025   raise Exception(message)
00026 
00027 def runUnitTest(path, testname):
00028   import sys
00029   import unittest
00030   setEnabled()
00031   if isinstance(path, basestring):
00032     sys.path.append(path)
00033   else:
00034     sys.path.extend(path)
00035   print "-------------------------------------------"
00036   print "path: %s\ntestname: %s" % (path, testname)
00037   print "-------------------------------------------"
00038   suite = unittest.TestLoader().loadTestsFromName(testname)
00039   result = unittest.TextTestRunner(verbosity=2).run(suite)
00040   if result.wasSuccessful():
00041     global _status
00042     _status = EXIT_SUCCESS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines