[Python-checkins] python/dist/src/Lib/test test_array.py,1.19,1.20 test_winsound.py,1.4,1.5

doerwalter@users.sourceforge.net doerwalter@users.sourceforge.net
Sat, 17 May 2003 17:47:49 -0700


Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1:/tmp/cvs-serv3817

Modified Files:
	test_array.py test_winsound.py 
Log Message:
Port test_array and test_winsound to PyUnit. Enhance tests for array
(code coverage for Modules/arraymodule.c is at 91%)

>From SF patch #736962.


Index: test_array.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_array.py,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -d -r1.19 -r1.20
*** test_array.py	7 Jan 2003 01:58:52 -0000	1.19
--- test_array.py	18 May 2003 00:47:46 -0000	1.20
***************
*** 3,381 ****
     Roger E. Masse
  """
- import array
- from test.test_support import verbose, TESTFN, unlink, TestFailed,\
-      have_unicode, vereq
  
! def main():
!     testtype('c', 'c')
!     if have_unicode:
!         testtype('u', unicode(r'\u263a', 'unicode-escape'))
[...1187 lines suppressed...]
!         self.assertAlmostEqual(entry1, entry2)
! 
! class FloatTest(FPTest):
!     typecode = 'f'
!     minitemsize = 4
! tests.append(FloatTest)
! 
! class DoubleTest(FPTest):
!     typecode = 'd'
!     minitemsize = 8
! tests.append(DoubleTest)
! 
! def test_main():
!     test_support.run_unittest(*tests)
! 
! if __name__=="__main__":
!     test_main()
! 
! 
! #main()

Index: test_winsound.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_winsound.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** test_winsound.py	9 Apr 2003 19:57:06 -0000	1.4
--- test_winsound.py	18 May 2003 00:47:46 -0000	1.5
***************
*** 1,18 ****
  # Ridiculously simple test of the winsound module for Windows.
  
  import winsound, time
! for i in range(100, 2000, 100):
!     winsound.Beep(i, 75)
! print "Hopefully you heard some sounds increasing in frequency!"
! winsound.MessageBeep()
! time.sleep(0.5)
! winsound.MessageBeep(winsound.MB_OK)
! time.sleep(0.5)
! winsound.MessageBeep(winsound.MB_ICONASTERISK)
! time.sleep(0.5)
! winsound.MessageBeep(winsound.MB_ICONEXCLAMATION)
! time.sleep(0.5)
! winsound.MessageBeep(winsound.MB_ICONHAND)
! time.sleep(0.5)
! winsound.MessageBeep(winsound.MB_ICONQUESTION)
! time.sleep(0.5)
--- 1,102 ----
  # Ridiculously simple test of the winsound module for Windows.
  
+ import unittest
+ from test import test_support
  import winsound, time
! 
! class BeepTest(unittest.TestCase):
! 
!     def test_errors(self):
!         self.assertRaises(TypeError, winsound.Beep)
!         self.assertRaises(ValueError, winsound.Beep, 36, 75)
!         self.assertRaises(ValueError, winsound.Beep, 32768, 75)
! 
!     def test_extremes(self):
!         winsound.Beep(37, 75)
!         winsound.Beep(32767, 75)
! 
!     def test_increasingfrequency(self):
!         for i in xrange(100, 2000, 100):
!             winsound.Beep(i, 75)
! 
! class MessageBeepTest(unittest.TestCase):
! 
!     def tearDown(self):
!         time.sleep(0.5)
! 
!     def test_default(self):
!         self.assertRaises(TypeError, winsound.MessageBeep, "bad")
!         self.assertRaises(TypeError, winsound.MessageBeep, 42, 42)
!         winsound.MessageBeep()
! 
!     def test_ok(self):
!         winsound.MessageBeep(winsound.MB_OK)
! 
!     def test_asterisk(self):
!         winsound.MessageBeep(winsound.MB_ICONASTERISK)
! 
!     def test_exclamation(self):
!         winsound.MessageBeep(winsound.MB_ICONEXCLAMATION)
! 
!     def test_hand(self):
!         winsound.MessageBeep(winsound.MB_ICONHAND)
! 
!     def test_question(self):
!         winsound.MessageBeep(winsound.MB_ICONQUESTION)
! 
! class PlaySoundTest(unittest.TestCase):
! 
!     def test_errors(self):
!         self.assertRaises(TypeError, winsound.PlaySound)
!         self.assertRaises(TypeError, winsound.PlaySound, "bad", "bad")
!         self.assertRaises(
!             RuntimeError,
!             winsound.PlaySound,
!             "none", winsound.SND_ASYNC | winsound.SND_MEMORY
!         )
! 
!     def test_alias_asterisk(self):
!         winsound.PlaySound('SystemAsterisk', winsound.SND_ALIAS)
! 
!     def test_alias_exclamation(self):
!         winsound.PlaySound('SystemExclamation', winsound.SND_ALIAS)
! 
!     def test_alias_exit(self):
!         winsound.PlaySound('SystemExit', winsound.SND_ALIAS)
! 
!     def test_alias_hand(self):
!         winsound.PlaySound('SystemHand', winsound.SND_ALIAS)
! 
!     def test_alias_question(self):
!         winsound.PlaySound('SystemQuestion', winsound.SND_ALIAS)
! 
!     def test_alias_fallback(self):
!         winsound.PlaySound('!"$%&/(#+*', winsound.SND_ALIAS)
! 
!     def test_alias_nofallback(self):
!         try:
!             winsound.PlaySound(
!                 '!"$%&/(#+*',
!                 winsound.SND_ALIAS | winsound.SND_NODEFAULT
!             )
!         except RuntimeError:
!             pass
! 
!     def test_stopasync(self):
!         winsound.PlaySound(
!             'SystemQuestion',
!             winsound.SND_ALIAS | winsound.SND_ASYNC | winsound.SND_LOOP
!         )
!         time.sleep(0.5)
!         self.assertRaises(
!             RuntimeError,
!             winsound.PlaySound,
!             'SystemQuestion', winsound.SND_ALIAS | winsound.SND_NOSTOP
!         )
!         winsound.PlaySound(None, winsound.SND_PURGE)
! 
! def test_main():
!     test_support.run_unittest(BeepTest, MessageBeepTest, PlaySoundTest)
! 
! if __name__=="__main__":
!     test_main()