Meshtastic Python Development
A note to developers of this lib
We use the Visual Studio Code (VScode) default python formatting conventions (autopep8). So if you use that IDE you should be able to use "Format Document" and not generate unrelated diffs. If you use some other editor, please do not change formatting on lines you have not changed yourself.
Building
To build a new release
apt install pandoc
sudo pip3 install markdown pdoc3 webencodings pyparsing twine autopep8 pylint pytest pytest-cov
For development
poetry install --all-extras --with dev,powermon
Linting
pylint meshtastic
Testing
Install and run pytest
- For more verbosity, add
-v
or even-vv
pip3 install .
pytest -vv
Run just unit tests
pytest
# or (more verbosely)
pytest -m unit
# or
make
Run just integration tests
pytest -m int
Run the smoke test with only one device connected serially (aka smoke1)
pytest -m smoke1
警告
Running smoke1
will reset values on the device, including the region to 1 (US).
Be sure to hit the reset button on the device after the test is completed.
Run the smoke test with only two device connected serially (aka smoke2)
pytest -m smoke2
Run the wifi smoke test
pytest -m smokewifi
Run a specific test
pytest -msmoke1 meshtastic/tests/test_smoke1.py::test_smoke1_info
# or to run a specific smoke2 test
pytest -m smoke2 meshtastic/tests/test_smoke2.py::test_smoke2_info
# or to run a specific smoke_wifi test
pytest -m smokewifi meshtastic/tests/test_smoke_wifi.py::test_smokewifi_info
Add another classification of tests such as unit
or smoke1
See pytest.ini.
To see the unit test code coverage
pytest --cov=meshtastic
# or if want html coverage report
pytest --cov-report html --cov=meshtastic
# or
make cov
To see slowest unit tests, you can run
pytest --durations=0
# or
make slow