summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_winsound.py
diff options
context:
space:
mode:
authorBrian Curtin <brian.curtin@gmail.com>2010-06-01 13:49:19 (GMT)
committerBrian Curtin <brian.curtin@gmail.com>2010-06-01 13:49:19 (GMT)
commitae16af2f408b453542698819b64e4c21993c6549 (patch)
tree7fe88a39575c4e957b44931e6675b3a9798cd73f /Lib/test/test_winsound.py
parentf4998acb5ab3c2fbbcb24e84ed7ed8721ab20f5c (diff)
downloadcpython-ae16af2f408b453542698819b64e4c21993c6549.zip
cpython-ae16af2f408b453542698819b64e4c21993c6549.tar.gz
cpython-ae16af2f408b453542698819b64e4c21993c6549.tar.bz2
Merged revisions 81640 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r81640 | brian.curtin | 2010-06-01 08:29:13 -0500 (Tue, 01 Jun 2010) | 3 lines Fix #8618. Ask the Windows mixer API if there are any playback devices configured before attempting to test PlaySound. ........
Diffstat (limited to 'Lib/test/test_winsound.py')
-rw-r--r--Lib/test/test_winsound.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/Lib/test/test_winsound.py b/Lib/test/test_winsound.py
index 88aed77..bd95048 100644
--- a/Lib/test/test_winsound.py
+++ b/Lib/test/test_winsound.py
@@ -6,6 +6,7 @@ support.requires('audio')
import time
import os
import subprocess
+import ctypes
winsound = support.import_module('winsound')
import winreg
@@ -13,6 +14,11 @@ import winreg
def has_sound(sound):
"""Find out if a particular event is configured with a default sound"""
try:
+ # Ask the mixer API for the number of devices it knows about.
+ # When there are no devices, PlaySound will fail.
+ if ctypes.windll.winmm.mixerGetNumDevs() is 0:
+ return False
+
key = winreg.OpenKeyEx(winreg.HKEY_CURRENT_USER,
"AppEvents\Schemes\Apps\.Default\{0}\.Default".format(sound))
value = winreg.EnumValue(key, 0)[1]