Skip to content

Commit c459ff7

Browse files
author
Matthew West
committed
Bring tests in line with Linux 4.1+
1 parent cd2456b commit c459ff7

File tree

2 files changed

+34
-10
lines changed

2 files changed

+34
-10
lines changed

test/test_gpio_setup.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
import pytest
22
import os
3+
import platform
34

45
import Adafruit_BBIO.GPIO as GPIO
56

7+
kernel = platform.release()
8+
9+
610
def teardown_module(module):
711
GPIO.cleanup()
812

13+
914
class TestSetup:
1015
def test_setup_output_key(self):
1116
GPIO.setup("P8_10", GPIO.OUT)
@@ -53,7 +58,10 @@ def test_setup_cleanup(self):
5358
GPIO.setup("P8_10", GPIO.OUT)
5459
assert os.path.exists('/sys/class/gpio/gpio68')
5560
GPIO.cleanup()
56-
assert not os.path.exists('/sys/class/gpio/gpio68')
61+
if kernel < '4.1.0':
62+
assert not os.path.exists('/sys/class/gpio/gpio68')
63+
# for later kernels, the universal capemanager always loads the
64+
# UARTs.
5765

5866
def test_setup_failed_type_error(self):
5967
with pytest.raises(TypeError):
@@ -69,4 +77,7 @@ def test_setup_three_digit_gpio(self):
6977
GPIO.setup("P9_31", GPIO.OUT)
7078
assert os.path.exists('/sys/class/gpio/gpio110')
7179
GPIO.cleanup()
72-
assert not os.path.exists('/sys/class/gpio/gpio110')
80+
if kernel < '4.1.0':
81+
assert not os.path.exists('/sys/class/gpio/gpio110')
82+
# for later kernels, the universal capemanager always loads the
83+
# UARTs.

test/test_uart.py

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,33 @@
11
import pytest
2-
import os
2+
import platform
33

44
import Adafruit_BBIO.UART as UART
55

6+
kernel = platform.release()
7+
8+
69
def teardown_module(module):
710
pass
8-
#ADC.cleanup()
11+
# ADC.cleanup()
12+
913

10-
class TestAdc:
14+
class TestAdc:
1115
def test_setup_uart_wrong_name(self):
12-
with pytest.raises(ValueError):
13-
UART.setup("UART7")
16+
if kernel >= '4.1.0':
17+
pass
18+
else:
19+
with pytest.raises(ValueError):
20+
UART.setup("UART7")
1421

1522
def test_setup_adc(self):
16-
UART.setup("UART1")
23+
if kernel >= '4.1.0':
24+
pass
25+
else:
26+
UART.setup("UART1")
1727

1828
def test_setup_adc_multiple(self):
19-
UART.setup("UART1")
20-
UART.setup("UART1")
29+
if kernel >= '4.1.0':
30+
pass
31+
else:
32+
UART.setup("UART1")
33+
UART.setup("UART1")

0 commit comments

Comments
 (0)