Skip to content

Commit

Permalink
Merge branch 'lurch-moar_tests'
Browse files Browse the repository at this point in the history
  • Loading branch information
waveform80 committed Feb 19, 2018
2 parents 7a0654c + 34fb671 commit 3c0e44c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
12 changes: 11 additions & 1 deletion tests/test_outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,9 @@ def test_rgbled_fade_background_nonpwm():
r, g, b = (Device.pin_factory.pin(i) for i in (1, 2, 3))
with RGBLED(1, 2, 3, pwm=False) as device:
with pytest.raises(ValueError):
device.blink(0, 0, 0.2, 0.2, n=2)
device.blink(0, 0, 0.2, 0, n=2)
with pytest.raises(ValueError):
device.blink(0, 0, 0, 0.2, n=2)

@pytest.mark.skipif(hasattr(sys, 'pypy_version_info'),
reason='timing is too random on pypy')
Expand Down Expand Up @@ -940,6 +942,10 @@ def test_motor_bad_value():
device.forward(2)
with pytest.raises(ValueError):
device.backward(2)
with pytest.raises(ValueError):
device.forward(-1)
with pytest.raises(ValueError):
device.backward(-1)

def test_motor_bad_value_nonpwm():
f = Device.pin_factory.pin(1)
Expand All @@ -953,6 +959,10 @@ def test_motor_bad_value_nonpwm():
device.value = 0.5
with pytest.raises(ValueError):
device.value = -0.5
with pytest.raises(ValueError):
device.forward(0.5)
with pytest.raises(ValueError):
device.backward(0.5)

def test_motor_reverse():
f = Device.pin_factory.pin(1)
Expand Down
8 changes: 8 additions & 0 deletions tests/test_spi.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ def test_spi_hardware_params():
with patch('gpiozero.pins.local.SpiDev'):
with factory.spi() as device:
assert isinstance(device, LocalPiHardwareSPI)
device.close()
assert device.closed
with factory.spi(port=0, device=0) as device:
assert isinstance(device, LocalPiHardwareSPI)
with factory.spi(port=0, device=1) as device:
Expand Down Expand Up @@ -66,8 +68,14 @@ def test_spi_software_params():
with patch('gpiozero.pins.local.SpiDev'):
with factory.spi(select_pin=6) as device:
assert isinstance(device, LocalPiSoftwareSPI)
device.close()
assert device.closed
with factory.spi(clock_pin=11, mosi_pin=9, miso_pin=10) as device:
assert isinstance(device, LocalPiSoftwareSPI)
device._bus.close()
assert device._bus.closed
device.close()
assert device.closed
with factory.spi(select_pin=6, shared=True) as device:
assert isinstance(device, LocalPiSoftwareSPIShared)
with patch('gpiozero.pins.local.SpiDev', None):
Expand Down

0 comments on commit 3c0e44c

Please sign in to comment.