According to the "Abstract Pin" documentation
Warning: Descendents must ensure that pin instances representing the same physical hardware are identical, right down to object identity.
and MockPin is a descendant of Pin. I realise the MockPin doesn't refer to actual hardware, but it might be nice (for the sake of the unit-tests) if
from gpiozero.pins.mock import MockPin
pin1 = MockPin(3)
pin2 = MockPin(3)
print(pin1 == pin2)
printed True, as it does for all the other Pin subclasses (with the current MockPin implementation it prints False).
In turn, this would allow us to have unit-tests for checking that e.g.
from gpiozero.pins.mock import MockPin
from gpiozero import LED
led1 = LED(MockPin(3))
pin2 = LED(MockPin(3))
fails with GPIOPinInUse as all the other Pin subclasses do.
I tried having a go myself at modifying the MockPin class to behave like the other Pin implementations (by changing __init__ to __new__ , adding a _PINS dict, etc.) but that just caused a whole load of problems with MockPWMPin then not working.
Feel free to close this issue, if it's irrelevant and I've misunderstood things!
According to the "Abstract Pin" documentation
and
MockPinis a descendant ofPin. I realise the MockPin doesn't refer to actual hardware, but it might be nice (for the sake of the unit-tests) ifprinted
True, as it does for all the otherPinsubclasses (with the current MockPin implementation it printsFalse).In turn, this would allow us to have unit-tests for checking that e.g.
fails with
GPIOPinInUseas all the otherPinsubclasses do.I tried having a go myself at modifying the MockPin class to behave like the other Pin implementations (by changing
__init__to__new__, adding a_PINSdict, etc.) but that just caused a whole load of problems withMockPWMPinthen not working.Feel free to close this issue, if it's irrelevant and I've misunderstood things!