Showcase for CircuitPython busio.I2CSlave work
The code and tests have not been cleaned up. It's the patchwork of the last weeks.
This plugin is needed to run the tests: pytest-circuitpython
Example run:
$ pytest --board=feather_m0_express --bus=1 i2cslave/
============================================================== test session starts ===============================================================
platform linux -- Python 3.5.3, pytest-3.6.3, py-1.5.4, pluggy-0.6.0
rootdir: /home/pi/work/circuitpython/cp-smbusslave/tests, inifile:
plugins: repeat-0.5.0, circuitpython-0.0.1
collected 1361 items
i2cslave/test_addressing.py .............................................................................................................. [ 8%]
.......................................................................................................................................... [ 18%]
.......................................................................................................... [ 26%]
i2cslave/test_read.py .................................................................................................................... [ 34%]
.......................................................................................................................................... [ 44%]
.................................................... [ 48%]
i2cslave/test_request.py ........................... [ 50%]
i2cslave/test_write.py ................................................................................................................... [ 58%]
....................................................................................................................... [ 67%]
i2cslave/test_write_read.py .............................................................................................................. [ 75%]
.......................................................................................................................................... [ 85%]
.......................................................................................................................................... [ 96%]
...................................................... [100%]
========================================================= 1361 passed in 129.98 seconds ==========================================================
$ pytest --board=feather_m0_express --bus=1 smbus/
============================================================== test session starts ===============================================================
platform linux -- Python 3.5.3, pytest-3.6.3, py-1.5.4, pluggy-0.6.0
rootdir: /home/pi/work/circuitpython/cp-smbusslave/tests, inifile:
plugins: repeat-0.5.0, circuitpython-0.0.1
collected 158 items
smbus/test_ads1015_linux.py .......... [ 6%]
smbus/test_at24_linux.py ........................................... [ 33%]
smbus/test_byte_word.py ................................................................ [ 74%]
smbus/test_ds1307.py . [ 74%]
smbus/test_ds1307_linux.py ........................................ [100%]
========================================================== 158 passed in 91.01 seconds ===========================================================
The pytest-repeat plugin can be used to put further stress on the code.
$ pytest --board=feather_m0_express --bus=1 smbus/test_at24_linux.py --count=100 --tb=no
============================================================== test session starts ===============================================================
platform linux -- Python 3.5.3, pytest-3.6.3, py-1.5.4, pluggy-0.6.0
rootdir: /home/pi/work/circuitpython/cp-smbusslave/tests, inifile:
plugins: repeat-0.5.0, circuitpython-0.0.1
collected 4300 items
smbus/test_at24_linux.py ................................................................................................................. [ 2%]
[...]
............................................... [100%]
========================================================= 4300 passed in 732.35 seconds ==========================================================