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

Add tests to avoid problems like #61 #62

Open
jmsv opened this issue Jun 2, 2017 · 2 comments
Open

Add tests to avoid problems like #61 #62

jmsv opened this issue Jun 2, 2017 · 2 comments

Comments

@jmsv
Copy link
Owner

jmsv commented Jun 2, 2017

Test coverage is currently awful - many more need to be made to prevent basic problems like #61

@alxwrd
Copy link
Collaborator

alxwrd commented Feb 6, 2018

hi @jamesevickery! I'm hoping to take a look at adding some tests this week/weekend. Have you had any thoughts on this? i.e. any weird edge cases?

A couple of links about mocking the RPi.GPIO module:

Mock objects look really useful for testing functionality around GPIO:

>>> from unittest.mock import MagicMock
>>> GPIO = MagicMock()

>>> GPIO.setmode(GPIO.BOARD)
<MagicMock name='mock.setmode()' id='140549155481584'>

>>> GPIO.setmode.assert_called_with(GPIO.BOARD)

>>> GPIO.setmode.assert_called_with(GPIO.BCM)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.6/unittest/mock.py", line 814, in assert_called_with
    raise AssertionError(_error_message()) from cause
AssertionError: Expected call: setmode(<MagicMock name='mock.BCM' id='140549155494208'>)
Actual call: setmode(<MagicMock name='mock.BOARD' id='140549155469016'>)

@jmsv
Copy link
Owner Author

jmsv commented Feb 9, 2018

@alxwrd This looks good 😄

Using MagicMock sounds like a good idea, feel free to add tests

@alxwrd alxwrd mentioned this issue Aug 18, 2018
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants