Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix module overloading for python2 on Raspbian #37

Open
precision opened this issue Nov 21, 2019 · 1 comment
Open

Fix module overloading for python2 on Raspbian #37

precision opened this issue Nov 21, 2019 · 1 comment

Comments

@precision
Copy link
Contributor

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)

@thatch
Copy link
Contributor

thatch commented Nov 22, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants