mirror of
				https://github.com/KevinMidboe/python-gpiozero.git
				synced 2025-10-29 17:50:37 +00:00 
			
		
		
		
	Merge pull request #218 from lurch/more_mockpin_tweaks
More small MockPin tweaks
This commit is contained in:
		| @@ -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): | ||||
|   | ||||
| @@ -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 | ||||
|   | ||||
		Reference in New Issue
	
	Block a user