mirror of https://github.com/python/cpython.git
Fix #7306. Add skips to test_winsound when no default sound is configured.
These failures occur on a Windows Server 2003 machine I test on.
This commit is contained in:
parent
ce6905245b
commit
d5c50b32aa
|
@ -5,9 +5,22 @@
|
||||||
import time
|
import time
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import _winreg
|
||||||
|
|
||||||
winsound = test_support.import_module('winsound')
|
winsound = test_support.import_module('winsound')
|
||||||
|
|
||||||
|
def has_sound(sound):
|
||||||
|
"""Find out if a particular event is configured with a default sound"""
|
||||||
|
try:
|
||||||
|
key = _winreg.OpenKeyEx(_winreg.HKEY_CURRENT_USER,
|
||||||
|
"AppEvents\Schemes\Apps\.Default\{0}\.Default".format(sound))
|
||||||
|
value = _winreg.EnumValue(key, 0)[1]
|
||||||
|
if value is not u"":
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
except WindowsError:
|
||||||
|
return False
|
||||||
|
|
||||||
class BeepTest(unittest.TestCase):
|
class BeepTest(unittest.TestCase):
|
||||||
# As with PlaySoundTest, incorporate the _have_soundcard() check
|
# As with PlaySoundTest, incorporate the _have_soundcard() check
|
||||||
|
@ -83,6 +96,7 @@ def test_errors(self):
|
||||||
"none", winsound.SND_ASYNC | winsound.SND_MEMORY
|
"none", winsound.SND_ASYNC | winsound.SND_MEMORY
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@unittest.skipUnless(has_sound("SystemAsterisk"), "No default SystemAsterisk")
|
||||||
def test_alias_asterisk(self):
|
def test_alias_asterisk(self):
|
||||||
if _have_soundcard():
|
if _have_soundcard():
|
||||||
winsound.PlaySound('SystemAsterisk', winsound.SND_ALIAS)
|
winsound.PlaySound('SystemAsterisk', winsound.SND_ALIAS)
|
||||||
|
@ -93,6 +107,7 @@ def test_alias_asterisk(self):
|
||||||
'SystemAsterisk', winsound.SND_ALIAS
|
'SystemAsterisk', winsound.SND_ALIAS
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@unittest.skipUnless(has_sound("SystemExclamation"), "No default SystemExclamation")
|
||||||
def test_alias_exclamation(self):
|
def test_alias_exclamation(self):
|
||||||
if _have_soundcard():
|
if _have_soundcard():
|
||||||
winsound.PlaySound('SystemExclamation', winsound.SND_ALIAS)
|
winsound.PlaySound('SystemExclamation', winsound.SND_ALIAS)
|
||||||
|
@ -103,6 +118,7 @@ def test_alias_exclamation(self):
|
||||||
'SystemExclamation', winsound.SND_ALIAS
|
'SystemExclamation', winsound.SND_ALIAS
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@unittest.skipUnless(has_sound("SystemExit"), "No default SystemExit")
|
||||||
def test_alias_exit(self):
|
def test_alias_exit(self):
|
||||||
if _have_soundcard():
|
if _have_soundcard():
|
||||||
winsound.PlaySound('SystemExit', winsound.SND_ALIAS)
|
winsound.PlaySound('SystemExit', winsound.SND_ALIAS)
|
||||||
|
@ -113,6 +129,7 @@ def test_alias_exit(self):
|
||||||
'SystemExit', winsound.SND_ALIAS
|
'SystemExit', winsound.SND_ALIAS
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@unittest.skipUnless(has_sound("SystemHand"), "No default SystemHand")
|
||||||
def test_alias_hand(self):
|
def test_alias_hand(self):
|
||||||
if _have_soundcard():
|
if _have_soundcard():
|
||||||
winsound.PlaySound('SystemHand', winsound.SND_ALIAS)
|
winsound.PlaySound('SystemHand', winsound.SND_ALIAS)
|
||||||
|
@ -123,6 +140,7 @@ def test_alias_hand(self):
|
||||||
'SystemHand', winsound.SND_ALIAS
|
'SystemHand', winsound.SND_ALIAS
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@unittest.skipUnless(has_sound("SystemQuestion"), "No default SystemQuestion")
|
||||||
def test_alias_question(self):
|
def test_alias_question(self):
|
||||||
if _have_soundcard():
|
if _have_soundcard():
|
||||||
winsound.PlaySound('SystemQuestion', winsound.SND_ALIAS)
|
winsound.PlaySound('SystemQuestion', winsound.SND_ALIAS)
|
||||||
|
|
Loading…
Reference in New Issue