Skip to content

Commit 9903992

Browse files
committed
add a few more tests for setup and output
1 parent 74e9df9 commit 9903992

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

test/test_gpio_output.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,18 @@ def test_output_low(self):
2121
assert not int(value)
2222
GPIO.cleanup()
2323

24+
def test_output_greater_than_one(self):
25+
GPIO.setup("P8_10", GPIO.OUT)
26+
GPIO.output("P8_10", 2)
27+
value = open('/sys/class/gpio/gpio68/value').read()
28+
assert int(value)
29+
GPIO.cleanup()
30+
31+
def test_output_of_pin_not_setup(self):
32+
with pytest.raises(RuntimeError):
33+
GPIO.output("P8_11", GPIO.LOW)
34+
GPIO.cleanup()
35+
2436
def test_output_setup_as_input(self):
2537
GPIO.setup("P8_10", GPIO.IN)
2638
with pytest.raises(RuntimeError):

test/test_gpio_setup.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,20 @@ def test_setup_output_name(self):
2121
assert direction == 'out\n'
2222
GPIO.cleanup()
2323

24-
def test_setup_input(self):
24+
def test_setup_input_key(self):
2525
GPIO.setup("P8_10", GPIO.IN)
2626
assert os.path.exists('/sys/class/gpio/gpio68')
2727
direction = open('/sys/class/gpio/gpio68/direction').read()
2828
assert direction == 'in\n'
2929
GPIO.cleanup()
3030

31+
def test_setup_input_name(self):
32+
GPIO.setup("TIMER6", GPIO.IN)
33+
assert os.path.exists('/sys/class/gpio/gpio68')
34+
direction = open('/sys/class/gpio/gpio68/direction').read()
35+
assert direction == 'in\n'
36+
GPIO.cleanup()
37+
3138
def test_setup_input_pull_up(self):
3239
GPIO.setup("P8_10", GPIO.IN, pull_up_down=GPIO.PUD_UP)
3340
assert os.path.exists('/sys/class/gpio/gpio68')

0 commit comments

Comments
 (0)