diff options
Diffstat (limited to 'Lib/test/test_winsound.py')
-rw-r--r-- | Lib/test/test_winsound.py | 29 |
1 files changed, 11 insertions, 18 deletions
diff --git a/Lib/test/test_winsound.py b/Lib/test/test_winsound.py index 34c3deaf7e..069adc3981 100644 --- a/Lib/test/test_winsound.py +++ b/Lib/test/test_winsound.py @@ -16,16 +16,12 @@ def has_sound(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: + if ctypes.windll.winmm.mixerGetNumDevs() == 0: return False 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 "": - return True - else: - return False + return winreg.EnumValue(key, 0)[1] != "" except WindowsError: return False @@ -162,18 +158,15 @@ class PlaySoundTest(unittest.TestCase): ) def test_alias_fallback(self): - # This test can't be expected to work on all systems. The MS - # PlaySound() docs say: - # - # If it cannot find the specified sound, PlaySound uses the - # default system event sound entry instead. If the function - # can find neither the system default entry nor the default - # sound, it makes no sound and returns FALSE. - # - # It's known to return FALSE on some real systems. - - # winsound.PlaySound('!"$%&/(#+*', winsound.SND_ALIAS) - return + # In the absense of the ability to tell if a sound was actually + # played, this test has two acceptable outcomes: success (no error, + # sound was theoretically played; although as issue #19987 shows + # a box without a soundcard can "succeed") or RuntimeError. Any + # other error is a failure. + try: + winsound.PlaySound('!"$%&/(#+*', winsound.SND_ALIAS) + except RuntimeError: + pass def test_alias_nofallback(self): if _have_soundcard(): |