diff --git a/gpiozero/pins/mock.py b/gpiozero/pins/mock.py index c260c6f..91d4b6a 100644 --- a/gpiozero/pins/mock.py +++ b/gpiozero/pins/mock.py @@ -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): diff --git a/tests/test_mock_pin.py b/tests/test_mock_pin.py index 857e340..92e1d3d 100644 --- a/tests/test_mock_pin.py +++ b/tests/test_mock_pin.py @@ -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