00001
00002
00003 __file__ = 'test-general.py'
00004 __title__ = 'This is the test of the general module.'
00005 __version__ = '0.1'
00006 __author__ = 'Olivier Boudeville (olivier.boudeville@online.fr)'
00007 __project__ = 'Ceylan'
00008 __creationDate__= '2004, January 31'
00009 __comments__ = 'Testing module.'
00010 __source__ = 'OSDL (http://osdl.sourceforge.net)'
00011 __doc__ = __title__ + '\n' + __comments__
00012
00013 __testTarget__ = 'generalUtils'
00014
00015
00016 from generalUtils import *
00017
00018
00019 print 'Beginning test of module %s.\n\n' % ( __testTarget__, )
00020
00021
00022 print 'Testing basic definitions...'
00023 print
00024
00025 print 'true is ', true
00026
00027 if true :
00028 print 'general.true is logically true.'
00029 else :
00030 print 'general.true is logically false.'
00031
00032 print 'false is ', false
00033
00034 if false :
00035 print 'general.false is logically true.'
00036 else :
00037 print 'general.false is logically false.'
00038
00039 print
00040 print '...done\n'
00041
00042
00043
00044
00045 print 'Testing ScreenDisplay...'
00046
00047 myScreenDisplay = ScreenDisplay()
00048
00049 myScreenDisplay.blankLine()
00050 print ' + testing channels'
00051
00052 myScreenDisplay( 'Hello, screen world !' )
00053 myScreenDisplay( 'Let the sun shine !' )
00054 myScreenDisplay.error( 'I made a mistake.' )
00055 myScreenDisplay.debug( 'I shall debug.' )
00056 myScreenDisplay.warning( 'I shall warn my users.' )
00057
00058 myScreenDisplay.blankLine()
00059 print ' + testing indentation'
00060
00061 myScreenDisplay.indent()
00062 myScreenDisplay( 'Let the sun shine ! (bis)' )
00063 myScreenDisplay( 'Let the sun shine ! (ter)' )
00064 myScreenDisplay.indent()
00065 myScreenDisplay( 'Let the sun shine ! (quattro ?)' )
00066 myScreenDisplay.desindent()
00067 myScreenDisplay.desindent()
00068 myScreenDisplay.desindent()
00069 myScreenDisplay( 'Let the sun shine ! (cinco ?)' )
00070 myScreenDisplay.error( 'I made a mistake.' )
00071
00072 myScreenDisplay.blankLine()
00073 print ' + testing string formatting'
00074
00075 myScreenDisplay.blankLine()
00076 print ' * testing string truncating'
00077
00078 myTruncateScreenDisplay = ScreenDisplay( truncate = 16 )
00079 myTruncateScreenDisplay( 'I am afraid I will be in some way truncated, my friend.' )
00080
00081 myScreenDisplay.blankLine()
00082 print ' * testing string spacing'
00083
00084 mySpacedScreenDisplay = ScreenDisplay( spacing = 15, truncate = 40 )
00085 mySpacedScreenDisplay( 'I', addReturn = false )
00086 mySpacedScreenDisplay( 'am', addReturn = false )
00087 mySpacedScreenDisplay( 'big', addReturn = true )
00088
00089 myScreenDisplay.blankLine()
00090 print ' * testing string compressing'
00091
00092 myCompressedScreenDisplay = ScreenDisplay( compression = true )
00093 myCompressedScreenDisplay( "I \nsuspect \nI \nwon't \nbe \nmultilined \nfor \nlong." )
00094
00095 myScreenDisplay.blankLine()
00096 print '...done\n'
00097
00098 myScreenDisplay.blankLine()
00099 print ' + testing verbosity management'
00100
00101 myScreenDisplay( 'I am a normal message and should be displayed.' )
00102 myScreenDisplay( Display.prefixForKeyMessages + 'I am an important message and should be displayed.' )
00103
00104 myScreenDisplay.setVerbosity( 1 )
00105 myScreenDisplay( 'I am a normal message and should not be displayed.' )
00106 myScreenDisplay( Display.prefixForKeyMessages + 'I am an important message and should be displayed.' )
00107
00108 myScreenDisplay.setVerbosity( 0 )
00109 myScreenDisplay( 'I am a normal message and should not be displayed.' )
00110 myScreenDisplay( Display.prefixForKeyMessages + 'I am an important message but should not be displayed.' )
00111 myScreenDisplay.blankLine()
00112
00113 print 'Testing FileDisplay...'
00114
00115 myFileDisplay = FileDisplay()
00116
00117 myFileDisplay( 'Hello, file world !' )
00118 myFileDisplay( 'This is a silly message indeed.' )
00119 myFileDisplay.error( 'I made a mistake.' )
00120 myFileDisplay.debug( 'I shall debug.' )
00121 myFileDisplay.warning( 'I shall warn my users.' )
00122
00123 print '...done\n'
00124
00125
00126 print 'End of test for module %s.\n\n' % ( __testTarget__, )
00127
00128