mirror of
https://github.com/KevinMidboe/python-gpiozero.git
synced 2025-10-29 17:50:37 +00:00
More small MockPin tweaks
This commit is contained in:
@@ -49,7 +49,7 @@ class MockPin(Pin):
|
|||||||
self.clear_states()
|
self.clear_states()
|
||||||
return self
|
return self
|
||||||
if old_pin.__class__ != cls:
|
if old_pin.__class__ != cls:
|
||||||
raise ValueError('pin %d is already in use as a %s' % (number, old_pin.__class__))
|
raise ValueError('pin %d is already in use as a %s' % (number, old_pin.__class__.__name__))
|
||||||
return old_pin
|
return old_pin
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ def teardown_function(function):
|
|||||||
# enough to get reasonable coverage but it's by no means comprehensive...
|
# enough to get reasonable coverage but it's by no means comprehensive...
|
||||||
|
|
||||||
def test_mock_pin_init():
|
def test_mock_pin_init():
|
||||||
|
with pytest.raises(TypeError):
|
||||||
|
MockPin()
|
||||||
with pytest.raises(ValueError):
|
with pytest.raises(ValueError):
|
||||||
MockPin(60)
|
MockPin(60)
|
||||||
assert MockPin(2).number == 2
|
assert MockPin(2).number == 2
|
||||||
@@ -53,6 +55,8 @@ def test_mock_pin_init_twice_different_pin():
|
|||||||
assert pin2.number == pin1.number+1
|
assert pin2.number == pin1.number+1
|
||||||
|
|
||||||
def test_mock_pwm_pin_init():
|
def test_mock_pwm_pin_init():
|
||||||
|
with pytest.raises(TypeError):
|
||||||
|
MockPWMPin()
|
||||||
with pytest.raises(ValueError):
|
with pytest.raises(ValueError):
|
||||||
MockPWMPin(60)
|
MockPWMPin(60)
|
||||||
assert MockPWMPin(2).number == 2
|
assert MockPWMPin(2).number == 2
|
||||||
|
|||||||
Reference in New Issue
Block a user