You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
One other change that I think is worth making: In authbox/__init__.py we have logic to replace RPi.GPIO on the import path with a fake if the real one is missing. But if you try running unit tests outside of venv, on Raspbian, and with Python2, then the real GPIO is already installed by default and it prevents unit tests from working.
Now that tests are in their own module, I think authbox/tests/__init__.py should instead do the fake RPi.GPIO replacement unconditionally.
A higher level design question though is how do we want to handle this kind of dependency injection going forward? We're doing it globally for GPIO, but via __init__() for fake queue/timer. We could also have each unit test patch the module under test.
The reason it was necessary to do it in __init__.py was the api stuff assumes that GPIO is importable, and the constructors for PinThreads etc doesn't take a reference to GPIO. I'm all for more testability here -- it just means either still having a try/except ImportError somewhere, or passing to (every) constructor.
One other change that I think is worth making: In
authbox/__init__.py
we have logic to replace RPi.GPIO on the import path with a fake if the real one is missing. But if you try running unit tests outside of venv, on Raspbian, and with Python2, then the real GPIO is already installed by default and it prevents unit tests from working.Now that tests are in their own module, I think
authbox/tests/__init__.py
should instead do the fake RPi.GPIO replacement unconditionally.A higher level design question though is how do we want to handle this kind of dependency injection going forward? We're doing it globally for GPIO, but via
__init__()
for fake queue/timer. We could also have each unit test patch the module under test.Originally posted by @thvortex in #36 (comment)
The text was updated successfully, but these errors were encountered: