Merge pull request #218 from lurch/more_mockpin_tweaks

More small MockPin tweaks
This commit is contained in:
Dave Jones
2016-02-21 01:33:30 +00:00
2 changed files with 5 additions and 1 deletions

View File

@@ -49,7 +49,7 @@ class MockPin(Pin):
self.clear_states()
return self
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
def __repr__(self):

View File

@@ -22,6 +22,8 @@ def teardown_function(function):
# enough to get reasonable coverage but it's by no means comprehensive...
def test_mock_pin_init():
with pytest.raises(TypeError):
MockPin()
with pytest.raises(ValueError):
MockPin(60)
assert MockPin(2).number == 2
@@ -53,6 +55,8 @@ def test_mock_pin_init_twice_different_pin():
assert pin2.number == pin1.number+1
def test_mock_pwm_pin_init():
with pytest.raises(TypeError):
MockPWMPin()
with pytest.raises(ValueError):
MockPWMPin(60)
assert MockPWMPin(2).number == 2