1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
import time
from playsound3 import AVAILABLE_BACKENDS, playsound
wav = "tests/sounds/звук 音 聲音.wav"
def test_with_blocking():
for backend in AVAILABLE_BACKENDS:
print(f"Testing backend: {backend}")
sound = playsound(wav, block=True, backend=backend)
assert not sound.is_alive()
def test_non_blocking():
for backend in AVAILABLE_BACKENDS:
print(f"Testing backend: {backend}")
sound = playsound(wav, block=False, backend=backend)
time.sleep(0.05)
assert sound.is_alive()
sound.wait()
assert not sound.is_alive()
|