adafruit-beaglebone-io-python/test/test_gpio_input.py
Zach Thorson d30657c1ae - Fixed broke GPIO.gpio_function() It should now allow calls with the IO Name
- Added unit tests for GPIO.gpio_function()
2013-07-29 16:53:11 -05:00

22 lines
611 B
Python

import pytest
import os
import Adafruit_BBIO.GPIO as GPIO
def teardown_module(module):
GPIO.cleanup()
class TestGPIOInput:
def test_input(self):
GPIO.setup("P8_10", GPIO.IN)
#returned as an int type
input_value = GPIO.input("P8_10")
#value read from the file will have a \n new line
value = open('/sys/class/gpio/gpio68/value').read()
assert int(value) == input_value
GPIO.cleanup()
def test_direction_readback(self):
GPIO.setup("P8_10", GPIO.IN)
direction = GPIO.gpio_function("P8_10")
assert direction == GPIO.IN