Skip to content
This repository was archived by the owner on Sep 30, 2019. It is now read-only.

Commit 8fa97f5

Browse files
committed
Update platform detection tests to use newer Pi platform detection logic and verify they pass.
1 parent 4f9dfde commit 8fa97f5

File tree

3 files changed

+9
-12
lines changed

3 files changed

+9
-12
lines changed

tests/test_GPIO.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
import Adafruit_GPIO as GPIO
2727
import Adafruit_GPIO.SPI as SPI
28+
import Adafruit_GPIO.Platform as Platform
2829

2930
from MockGPIO import MockGPIO
3031

@@ -211,17 +212,17 @@ def test_cleanup_pin(self):
211212

212213
class TestGetPlatformGPIO(unittest.TestCase):
213214
@patch.dict('sys.modules', {'RPi': Mock(), 'RPi.GPIO': Mock()})
214-
@patch('platform.platform', Mock(return_value='Linux-3.10.25+-armv6l-with-debian-7.4'))
215+
@patch('Adafruit_GPIO.Platform.platform_detect', Mock(return_value=Platform.RASPBERRY_PI))
215216
def test_raspberrypi(self):
216217
gpio = GPIO.get_platform_gpio()
217218
self.assertIsInstance(gpio, GPIO.RPiGPIOAdapter)
218219

219220
@patch.dict('sys.modules', {'Adafruit_BBIO': Mock(), 'Adafruit_BBIO.GPIO': Mock()})
220-
@patch('platform.platform', Mock(return_value='Linux-3.8.13-bone47-armv7l-with-debian-7.4'))
221+
@patch('Adafruit_GPIO.Platform.platform_detect', Mock(return_value=Platform.BEAGLEBONE_BLACK))
221222
def test_beagleboneblack(self):
222223
gpio = GPIO.get_platform_gpio()
223224
self.assertIsInstance(gpio, GPIO.AdafruitBBIOAdapter)
224225

225-
@patch('platform.platform', Mock(return_value='Darwin-13.2.0-x86_64-i386-64bit'))
226-
def test_otherplatform(self):
226+
@patch('Adafruit_GPIO.Platform.platform_detect', Mock(return_value=Platform.UNKNOWN))
227+
def test_unknown(self):
227228
self.assertRaises(RuntimeError, GPIO.get_platform_gpio)

tests/test_PWM.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
from mock import Mock, patch
2525

2626
import Adafruit_GPIO.PWM as PWM
27+
import Adafruit_GPIO.Platform as Platform
2728

2829

2930
class TestRPi_PWM_Adapter(unittest.TestCase):
@@ -86,17 +87,17 @@ def test_set_frequency(self):
8687

8788
class TestGetPlatformPWM(unittest.TestCase):
8889
@patch.dict('sys.modules', {'RPi': Mock(), 'RPi.GPIO': Mock()})
89-
@patch('platform.platform', Mock(return_value='Linux-3.10.25+-armv6l-with-debian-7.4'))
90+
@patch('Adafruit_GPIO.Platform.platform_detect', Mock(return_value=Platform.RASPBERRY_PI))
9091
def test_raspberrypi(self):
9192
pwm = PWM.get_platform_pwm()
9293
self.assertIsInstance(pwm, PWM.RPi_PWM_Adapter)
9394

9495
@patch.dict('sys.modules', {'Adafruit_BBIO': Mock(), 'Adafruit_BBIO.PWM': Mock()})
95-
@patch('platform.platform', Mock(return_value='Linux-3.8.13-bone47-armv7l-with-debian-7.4'))
96+
@patch('Adafruit_GPIO.Platform.platform_detect', Mock(return_value=Platform.BEAGLEBONE_BLACK))
9697
def test_beagleboneblack(self):
9798
pwm = PWM.get_platform_pwm()
9899
self.assertIsInstance(pwm, PWM.BBIO_PWM_Adapter)
99100

100-
@patch('platform.platform', Mock(return_value='Darwin-13.2.0-x86_64-i386-64bit'))
101+
@patch('Adafruit_GPIO.Platform.platform_detect', Mock(return_value=Platform.UNKNOWN))
101102
def test_otherplatform(self):
102103
self.assertRaises(RuntimeError, PWM.get_platform_pwm)

tests/test_Platform.py

-5
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,6 @@
2626

2727

2828
class TestPlatformDetect(unittest.TestCase):
29-
@patch('platform.platform', Mock(return_value='Linux-3.10.25+-armv6l-with-debian-7.4'))
30-
def test_raspberry_pi(self):
31-
result = Platform.platform_detect()
32-
self.assertEquals(result, Platform.RASPBERRY_PI)
33-
3429
@patch('platform.platform', Mock(return_value='Linux-3.8.13-bone47-armv7l-with-debian-7.4'))
3530
def test_beaglebone_black(self):
3631
result = Platform.platform_detect()

0 commit comments

Comments
 (0)