Skip to content

Commit 5be86ae

Browse files
committed
pytest set device
1 parent 0fb3a68 commit 5be86ae

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

tests/conftest.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# content of conftest.py
2+
import pytest
3+
4+
5+
def pytest_addoption(parser):
6+
parser.addoption(
7+
"--device",
8+
action="store",
9+
default=None,
10+
help='Set the alsa device. Defaults to `None`.'
11+
)
12+
13+
14+
@pytest.fixture
15+
def device(request):
16+
return request.config.getoption('--device')

tests/test_school_bell.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from school_bell.school_bell import SchoolBell, _validate_day, _validate_time
44

55

6-
def create_args(holidays: str = None):
6+
def create_args(device):
77
return {
88
'schedule': {
99
'Wed': {
@@ -16,6 +16,7 @@ def create_args(holidays: str = None):
1616
'1': 'SchoolBell-SoundBible.com-449398625.wav'
1717
},
1818
'root': f"{getcwd()}/samples",
19+
'device': device,
1920
'test': True,
2021
'timeout': 10,
2122
'holidays': 'NL-BE',
@@ -46,8 +47,8 @@ def test_validate_time():
4647
assert _validate_time("00:00:60") is False
4748

4849

49-
def test_school_bell():
50-
bell = SchoolBell(**create_args())
51-
assert bell.play(0) == True
50+
def test_school_bell(device):
51+
bell = SchoolBell(**create_args(device))
52+
assert bell.play(0) is True
5253
assert bell.ring(1) != bell.is_holiday()
5354
assert bell.run_schedule(_test_mode=True) is True

0 commit comments

Comments
 (0)