summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTrent Nelson <trent.nelson@snakebite.org>2008-03-18 03:52:22 (GMT)
committerTrent Nelson <trent.nelson@snakebite.org>2008-03-18 03:52:22 (GMT)
commita6f5bf2387ad21325abc222730273d7f01618ef3 (patch)
tree05fba5221cb382e0e1bd2750c6ae3a360ee785b8
parent756c6c8cf40f4b75deac22a709efc891929ae053 (diff)
downloadcpython-a6f5bf2387ad21325abc222730273d7f01618ef3.zip
cpython-a6f5bf2387ad21325abc222730273d7f01618ef3.tar.gz
cpython-a6f5bf2387ad21325abc222730273d7f01618ef3.tar.bz2
Ensure this test passes even if there are no soundcards in the system. Backport from trunk r61242.
-rw-r--r--Lib/test/test_winsound.py20
1 files changed, 16 insertions, 4 deletions
diff --git a/Lib/test/test_winsound.py b/Lib/test/test_winsound.py
index 19d4459..5606c44 100644
--- a/Lib/test/test_winsound.py
+++ b/Lib/test/test_winsound.py
@@ -8,6 +8,13 @@ import subprocess
class BeepTest(unittest.TestCase):
+ # As with PlaySoundTest, incorporate the _have_soundcard() check
+ # into our test methods. If there's no audio device present,
+ # winsound.Beep returns 0 and GetLastError() returns 127, which
+ # is: ERROR_PROC_NOT_FOUND ("The specified procedure could not
+ # be found"). (FWIW, virtual/Hyper-V systems fall under this
+ # scenario as they have no sound devices whatsoever (not even
+ # a legacy Beep device).)
def test_errors(self):
self.assertRaises(TypeError, winsound.Beep)
@@ -15,12 +22,17 @@ class BeepTest(unittest.TestCase):
self.assertRaises(ValueError, winsound.Beep, 32768, 75)
def test_extremes(self):
- winsound.Beep(37, 75)
- winsound.Beep(32767, 75)
+ if _have_soundcard():
+ winsound.Beep(37, 75)
+ winsound.Beep(32767, 75)
+ else:
+ self.assertRaises(RuntimeError, winsound.Beep, 37, 75)
+ self.assertRaises(RuntimeError, winsound.Beep, 32767, 75)
def test_increasingfrequency(self):
- for i in xrange(100, 2000, 100):
- winsound.Beep(i, 75)
+ if _have_soundcard():
+ for i in xrange(100, 2000, 100):
+ winsound.Beep(i, 75)
class MessageBeepTest(unittest.TestCase):