Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8bcbe6a

Browse files
committed
Don't require that a RuntimeError is raised when playing a second
sound while the first one is still running, as the first one one might already have finished. Fixes part of SF bug #763052.
1 parent ccd615c commit 8bcbe6a

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

Lib/test/test_winsound.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,15 @@ def test_stopasync(self):
8888
winsound.SND_ALIAS | winsound.SND_ASYNC | winsound.SND_LOOP
8989
)
9090
time.sleep(0.5)
91-
self.assertRaises(
92-
RuntimeError,
93-
winsound.PlaySound,
94-
'SystemQuestion', winsound.SND_ALIAS | winsound.SND_NOSTOP
95-
)
91+
try:
92+
winsound.PlaySound(
93+
'SystemQuestion',
94+
winsound.SND_ALIAS | winsound.SND_NOSTOP
95+
)
96+
except RuntimeError:
97+
pass
98+
else: # the first sound might already be finished
99+
pass
96100
winsound.PlaySound(None, winsound.SND_PURGE)
97101

98102
def test_main():

0 commit comments

Comments
 (0)