summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Curtin <brian.curtin@gmail.com>2010-06-01 13:29:13 (GMT)
committerBrian Curtin <brian.curtin@gmail.com>2010-06-01 13:29:13 (GMT)
commit824912eb30d64c196e88602e5488803d8f16991a (patch)
tree3495228f81e68b57b8b0d3aff6ccf5e08515fed0
parent4f0108b0d9db4f992dd9e34ce899a54631fe6351 (diff)
downloadcpython-824912eb30d64c196e88602e5488803d8f16991a.zip
cpython-824912eb30d64c196e88602e5488803d8f16991a.tar.gz
cpython-824912eb30d64c196e88602e5488803d8f16991a.tar.bz2
Fix #8618. Ask the Windows mixer API if there are any playback devices
configured before attempting to test PlaySound.
-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 228dfa1..366c74b 100644
--- a/Lib/test/test_winsound.py
+++ b/Lib/test/test_winsound.py
@@ -5,6 +5,7 @@ from test import test_support
import time
import os
import subprocess
+import ctypes
winsound = test_support.import_module('winsound')
import _winreg
@@ -12,6 +13,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]