diff options
author | Brian Curtin <brian.curtin@gmail.com> | 2010-04-13 02:32:40 (GMT) |
---|---|---|
committer | Brian Curtin <brian.curtin@gmail.com> | 2010-04-13 02:32:40 (GMT) |
commit | 36067606707844f7de076cf1846afb767b494d7e (patch) | |
tree | fa854f4f1d6c0b57b44f5935266214be54238cc4 /Lib/test/test_winsound.py | |
parent | fb1d3c1cc75eb8494dab1b0315f2eb4c0989f387 (diff) | |
download | cpython-36067606707844f7de076cf1846afb767b494d7e.zip cpython-36067606707844f7de076cf1846afb767b494d7e.tar.gz cpython-36067606707844f7de076cf1846afb767b494d7e.tar.bz2 |
Merged revisions 80026 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r80026 | brian.curtin | 2010-04-12 21:25:20 -0500 (Mon, 12 Apr 2010) | 4 lines
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.
........
Diffstat (limited to 'Lib/test/test_winsound.py')
-rw-r--r-- | Lib/test/test_winsound.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/Lib/test/test_winsound.py b/Lib/test/test_winsound.py index 3a093fd..a33400e 100644 --- a/Lib/test/test_winsound.py +++ b/Lib/test/test_winsound.py @@ -6,9 +6,22 @@ support.requires('audio') import time import os import subprocess +import winreg winsound = 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): # As with PlaySoundTest, incorporate the _have_soundcard() check @@ -84,6 +97,8 @@ class PlaySoundTest(unittest.TestCase): "none", winsound.SND_ASYNC | winsound.SND_MEMORY ) + @unittest.skipUnless(has_sound("SystemAsterisk"), + "No default SystemAsterisk") def test_alias_asterisk(self): if _have_soundcard(): winsound.PlaySound('SystemAsterisk', winsound.SND_ALIAS) @@ -94,6 +109,8 @@ class PlaySoundTest(unittest.TestCase): 'SystemAsterisk', winsound.SND_ALIAS ) + @unittest.skipUnless(has_sound("SystemExclamation"), + "No default SystemExclamation") def test_alias_exclamation(self): if _have_soundcard(): winsound.PlaySound('SystemExclamation', winsound.SND_ALIAS) @@ -104,6 +121,7 @@ class PlaySoundTest(unittest.TestCase): 'SystemExclamation', winsound.SND_ALIAS ) + @unittest.skipUnless(has_sound("SystemExit"), "No default SystemExit") def test_alias_exit(self): if _have_soundcard(): winsound.PlaySound('SystemExit', winsound.SND_ALIAS) @@ -114,6 +132,7 @@ class PlaySoundTest(unittest.TestCase): 'SystemExit', winsound.SND_ALIAS ) + @unittest.skipUnless(has_sound("SystemHand"), "No default SystemHand") def test_alias_hand(self): if _have_soundcard(): winsound.PlaySound('SystemHand', winsound.SND_ALIAS) @@ -124,6 +143,8 @@ class PlaySoundTest(unittest.TestCase): 'SystemHand', winsound.SND_ALIAS ) + @unittest.skipUnless(has_sound("SystemQuestion"), + "No default SystemQuestion") def test_alias_question(self): if _have_soundcard(): winsound.PlaySound('SystemQuestion', winsound.SND_ALIAS) |