Merge pull request 'add-pytest-infrastructure' (#38) from add-pytest-infrastructure into main
All checks were successful
Build RPi Pico firmware image / Build-Firmware (push) Successful in 3m20s
Check code formatting / Check-C-Format (push) Successful in 7s
Check code formatting / Check-Python-Flake8 (push) Successful in 9s
Check code formatting / Check-Bash-Shellcheck (push) Successful in 5s
Run unit tests on host / Run-Unit-Tests (push) Successful in 8s
Run pytests / Check-Pytest (push) Successful in 10s
All checks were successful
Build RPi Pico firmware image / Build-Firmware (push) Successful in 3m20s
Check code formatting / Check-C-Format (push) Successful in 7s
Check code formatting / Check-Python-Flake8 (push) Successful in 9s
Check code formatting / Check-Bash-Shellcheck (push) Successful in 5s
Run unit tests on host / Run-Unit-Tests (push) Successful in 8s
Run pytests / Check-Pytest (push) Successful in 10s
Reviewed-on: #38 Reviewed-by: Stefan Kratochwil <kratochwil-la@gmx.de>
This commit was merged in pull request #38.
This commit is contained in:
@@ -25,8 +25,11 @@ jobs:
|
||||
path: git
|
||||
- name: Check python
|
||||
run: |
|
||||
cd git/software/src &&
|
||||
find . -iname '*.py' -exec ../../../flake-venv/bin/flake8 {} +
|
||||
cd git/software && (
|
||||
find src -iname '*.py' -exec ../../flake-venv/bin/flake8 {} +
|
||||
find tests -iname '*.py' -exec ../../flake-venv/bin/flake8 {} +
|
||||
find modules -iname '*.py' -exec ../../flake-venv/bin/flake8 {} +
|
||||
)
|
||||
Check-Bash-Shellcheck:
|
||||
runs-on: ubuntu-22.04-full
|
||||
steps:
|
||||
|
||||
24
.gitea/workflows/unit-tests-python.yaml
Normal file
24
.gitea/workflows/unit-tests-python.yaml
Normal file
@@ -0,0 +1,24 @@
|
||||
# SPDX-License-Identifier: MIT
|
||||
# Copyright (c) 2025 Matthias Blankertz <matthias@blankertz.org>
|
||||
---
|
||||
name: Run pytests
|
||||
"on":
|
||||
push:
|
||||
|
||||
jobs:
|
||||
Check-Pytest:
|
||||
runs-on: ubuntu-22.04-full
|
||||
steps:
|
||||
- name: Check out repository code
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
path: git
|
||||
- name: Get dependencies
|
||||
run: |
|
||||
python -m venv test-venv
|
||||
test-venv/bin/pip install -r git/software/tests/requirements.txt
|
||||
- name: Run pytest
|
||||
run: |
|
||||
. test-venv/bin/activate &&
|
||||
cd git/software &&
|
||||
pytest
|
||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -3,6 +3,9 @@ hardware/tonberry-pico/tonberry-pico-backups/
|
||||
*.kicad_sch-bak
|
||||
*.kicad_sch.lck
|
||||
software/build
|
||||
software/typings
|
||||
compile_commands.json
|
||||
.dir-locals.el
|
||||
.cache
|
||||
\#*#
|
||||
__pycache__
|
||||
|
||||
11
DEVELOP.md
Normal file
11
DEVELOP.md
Normal file
@@ -0,0 +1,11 @@
|
||||
# Developer notes
|
||||
|
||||
## How to setup python environment for mypy and pytest
|
||||
|
||||
```bash
|
||||
cd software
|
||||
python -m venv test-venv
|
||||
. test-venv/bin/activate
|
||||
pip install -r tests/requirements.txt
|
||||
pip install -U micropython-rp2-pico_w-stubs --target typings
|
||||
```
|
||||
9
software/mypy.ini
Normal file
9
software/mypy.ini
Normal file
@@ -0,0 +1,9 @@
|
||||
[mypy]
|
||||
platform = linux
|
||||
mypy_path = $MYPY_CONFIG_FILE_DIR/src:$MYPY_CONFIG_FILE_DIR/typings
|
||||
custom_typeshed_dir = $MYPY_CONFIG_FILE_DIR/typings
|
||||
follow_imports = silent
|
||||
exclude = "typings[\\/].*"
|
||||
follow_imports_for_stubs = true
|
||||
no_site_packages = true
|
||||
check_untyped_defs = true
|
||||
3
software/pytest.ini
Normal file
3
software/pytest.ini
Normal file
@@ -0,0 +1,3 @@
|
||||
[pytest]
|
||||
pythonpath = tests/mocks src
|
||||
testpaths = tests
|
||||
@@ -1,7 +1,7 @@
|
||||
# SPDX-License-Identifier: MIT
|
||||
# Copyright (c) 2024-2025 Matthias Blankertz <matthias@blankertz.org>
|
||||
|
||||
import aiorepl
|
||||
import aiorepl # type: ignore
|
||||
import asyncio
|
||||
import machine
|
||||
import micropython
|
||||
|
||||
@@ -17,7 +17,7 @@ if TYPE_CHECKING:
|
||||
|
||||
|
||||
class Buttons:
|
||||
def __init__(self, cb: ButtonCallback, pin_volup=17, pin_voldown=19, pin_next=18):
|
||||
def __init__(self, cb: "ButtonCallback", pin_volup=17, pin_voldown=19, pin_next=18):
|
||||
self.VOLUP = micropython.const(1)
|
||||
self.VOLDOWN = micropython.const(2)
|
||||
self.NEXT = micropython.const(3)
|
||||
|
||||
2
software/tests/mocks/machine.py
Normal file
2
software/tests/mocks/machine.py
Normal file
@@ -0,0 +1,2 @@
|
||||
# SPDX-License-Identifier: MIT
|
||||
# Copyright (c) 2025 Matthias Blankertz <matthias@blankertz.org>
|
||||
2
software/tests/mocks/micropython.py
Normal file
2
software/tests/mocks/micropython.py
Normal file
@@ -0,0 +1,2 @@
|
||||
# SPDX-License-Identifier: MIT
|
||||
# Copyright (c) 2025 Matthias Blankertz <matthias@blankertz.org>
|
||||
5
software/tests/mocks/rp2_sd.py
Normal file
5
software/tests/mocks/rp2_sd.py
Normal file
@@ -0,0 +1,5 @@
|
||||
# SPDX-License-Identifier: MIT
|
||||
# Copyright (c) 2025 Matthias Blankertz <matthias@blankertz.org>
|
||||
|
||||
class SDCard():
|
||||
pass
|
||||
1
software/tests/requirements.txt
Normal file
1
software/tests/requirements.txt
Normal file
@@ -0,0 +1 @@
|
||||
pytest
|
||||
3
software/tests/test_dummy.py
Normal file
3
software/tests/test_dummy.py
Normal file
@@ -0,0 +1,3 @@
|
||||
def test_dummy():
|
||||
# This is just a dummy test to make pytest not fail because no tests are defined
|
||||
pass
|
||||
0
software/tests/utils_test/__init__.py
Normal file
0
software/tests/utils_test/__init__.py
Normal file
Reference in New Issue
Block a user