summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDevaev Maxim <[email protected]>2019-04-12 17:30:48 +0300
committerDevaev Maxim <[email protected]>2019-04-12 17:30:48 +0300
commit5bf758e232361e2b7a6b64e4b1750a10d896bb2d (patch)
tree94954f6dfa7b3408fccbad232a367811be539497
parent428e4840ac001fc2edda53285bb1c6e0677d6bac (diff)
better gpio tests
-rw-r--r--tests/test_gpio.py41
1 files changed, 25 insertions, 16 deletions
diff --git a/tests/test_gpio.py b/tests/test_gpio.py
index f930f92f..6a02816d 100644
--- a/tests/test_gpio.py
+++ b/tests/test_gpio.py
@@ -20,30 +20,39 @@
# ========================================================================== #
+import pytest
+
from kvmd import gpio
# =====
-def test_ok__loopback_initial_false() -> None:
- # pylint: disable=singleton-comparison
[email protected]("pin", [0, 1, 13])
+def test_ok__loopback_initial_false(pin: int) -> None:
with gpio.bcm():
- assert gpio.set_output(0) == 0
- assert gpio.read(0) is False
- gpio.write(0, True)
- assert gpio.read(0) is True
+ assert gpio.set_output(pin) == pin
+ assert gpio.read(pin) is False
+ gpio.write(pin, True)
+ assert gpio.read(pin) is True
-def test_ok__loopback_initial_true() -> None:
- # pylint: disable=singleton-comparison
[email protected]("pin", [0, 1, 13])
+def test_ok__loopback_initial_true(pin: int) -> None:
with gpio.bcm():
- assert gpio.set_output(0, True) == 0
- assert gpio.read(0) is True
- gpio.write(0, False)
- assert gpio.read(0) is False
+ assert gpio.set_output(pin, True) == pin
+ assert gpio.read(pin) is True
+ gpio.write(pin, False)
+ assert gpio.read(pin) is False
-def test_ok__input() -> None:
- # pylint: disable=singleton-comparison
[email protected]("pin", [0, 1, 13])
+def test_ok__input(pin: int) -> None:
with gpio.bcm():
- assert gpio.set_input(0) == 0
- assert gpio.read(0) is False
+ assert gpio.set_input(pin) == pin
+ assert gpio.read(pin) is False
+
+
+def test_fail__invalid_pin() -> None:
+ with pytest.raises(AssertionError):
+ gpio.set_output(-1)
+ with pytest.raises(AssertionError):
+ gpio.set_input(-1)