File: test_raising_errors.py

package info (click to toggle)
python-playsound3 3.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 880 kB
  • sloc: python: 540; sh: 10; makefile: 4
file content (29 lines) | stat: -rw-r--r-- 662 bytes parent folder | download
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
26
27
28
29
import urllib.error

import pytest

from playsound3 import playsound
from playsound3.playsound3 import PlaysoundException

valid = "tests/sounds/sample3s.mp3"


def test_invalid_sound_file():
    with pytest.raises(PlaysoundException):
        playsound("invalid.mp3")


def test_non_existent_file():
    with pytest.raises(PlaysoundException):
        playsound("non_existent.mp3")


def test_invalid_backend():
    with pytest.raises(PlaysoundException):
        playsound(valid, backend="invalid_backend")


def test_playsound_from_url():
    url = "https://wrong-url.com/wrong-audio.mp3"
    with pytest.raises(urllib.error.URLError):
        playsound(url)