]> granicus.if.org Git - python/commitdiff
Issue #19987: Re-write test_alias_fallback in test_winsound to have two
authorZachary Ware <zachary.ware@gmail.com>
Mon, 16 Dec 2013 14:58:10 +0000 (08:58 -0600)
committerZachary Ware <zachary.ware@gmail.com>
Mon, 16 Dec 2013 14:58:10 +0000 (08:58 -0600)
acceptable outcomes: success or RuntimeError.  Without being able to
actually hear whether a sound was played, either one could be right, but
any other error would be a failure.

Lib/test/test_winsound.py
Misc/NEWS

index 6d8649abb914952210d9ba1a0ef333663dd43a36..4208fe71c4a7248d87acb3a5282ddb90381887a1 100644 (file)
@@ -159,14 +159,15 @@ class PlaySoundTest(unittest.TestCase):
             )
 
     def test_alias_fallback(self):
-        if _have_soundcard():
+        # 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)
-        else:
-            self.assertRaises(
-                RuntimeError,
-                winsound.PlaySound,
-                '!"$%&/(#+*', winsound.SND_ALIAS
-            )
+        except RuntimeError:
+            pass
 
     def test_alias_nofallback(self):
         if _have_soundcard():
index 44ec6f1611c13d0aed871dc48eaef50aba7a8f52..5a921c9020e8f0dc7dd5eb4db92cf562862cc9cd 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -101,7 +101,7 @@ Tests
 
 - Issue #19928: Implemented a test for repr() of cell objects.
 
-- Issue #19595: Re-enabled a long-disabled test in test_winsound.
+- Issue #19595, #19987: Re-enabled a long-disabled test in test_winsound.
 
 - Issue #19588: Fixed tests in test_random that were silently skipped most
   of the time.  Patch by Julian Gindi.