diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 16219b0bc..cab495a46 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -43,7 +43,7 @@ jobs: msgq/test_runner && \ msgq/visionipc/test_runner" - name: python tests - run: $RUN_NAMED "${{ matrix.backend }}=1 coverage run -m unittest discover ." + run: $RUN_NAMED "${{ matrix.backend }}=1 coverage run -m pytest" - name: Upload coverage run: | docker commit msgq msgqci diff --git a/Dockerfile b/Dockerfile index 982d8fa5b..5f533cd62 100644 --- a/Dockerfile +++ b/Dockerfile @@ -35,7 +35,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ zlib1g-dev \ && rm -rf /var/lib/apt/lists/* -RUN pip3 install --break-system-packages --no-cache-dir pyyaml Cython scons pycapnp pre-commit ruff parameterized coverage numpy +RUN pip3 install --break-system-packages --no-cache-dir pyyaml Cython scons pycapnp pre-commit ruff parameterized coverage numpy pytest pytest-xdist WORKDIR /project/msgq/ RUN cd /tmp/ && \ diff --git a/msgq/tests/test_messaging.py b/msgq/tests/test_messaging.py index a747708a7..cf54fa1b6 100644 --- a/msgq/tests/test_messaging.py +++ b/msgq/tests/test_messaging.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python3 import os import random import threading diff --git a/pyproject.toml b/pyproject.toml index 73928614e..5d0f0ae3d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,6 +7,10 @@ lint.flake8-implicit-str-concat.allow-multiline=false line-length = 160 target-version="py311" +[tool.ruff.lint.flake8-tidy-imports.banned-api] +"pytest.main".msg = "pytest.main requires special handling that is easy to mess up!" +"unittest".msg = "Use pytest" + [mypy.tool] # third-party packages ignore_missing_imports=true @@ -19,3 +23,11 @@ warn_unused_ignores=true # restrict dynamic typing warn_return_any=true check_untyped_defs=true + +[tool.pytest.ini_options] +addopts = "--durations=10 -n auto" +testpaths = [ + "msgq/tests", + "msgq/visionipc/tests", +] +