Testing¶
MedUX uses pytest with pytest-django for testing.
Running Tests¶
# Activate the project venv first (mandatory; see Setup)
source .venv/bin/activate
# Run all tests (from repo root)
pytest
# Run a specific test file
pytest src/medux/core/tests/test_names.py
# Run with coverage
coverage run -m pytest
Test Settings¶
Tests use a dedicated settings module: medux.tests.settings. This is
configured in pyproject.toml:
[tool.pytest.ini_options]
DJANGO_SETTINGS_MODULE = "medux.tests.settings"
pythonpath = ["src"]
The test settings use SQLite automatically — no .env file or
PostgreSQL setup needed for running tests.
Test Settings for Plugins¶
External plugins can reuse MedUX's test settings:
# tests/settings.py
from medux.tests.settings import * # noqa
# override as needed
Writing Tests¶
- Place tests in a
tests/directory within each app - Use
pytestfixtures and Django'sTestCasewhere appropriate - Use factories or fixtures for test data setup
Pre-Commit Checks¶
Run all tests before committing (venv active):
pytest
pre-commit run --all-files
Important
All tests must pass locally before creating a Git tag or release.