Testing & QA¶
Keep regressions away from your clinical workflows by leaning on the existing test suite and smoke runners. This page summarizes what already exists so you can extend it confidently.
Actively tested Python and desktop matrix¶
The core SDK supports CPython 3.11, 3.12, 3.13, 3.14 and 3.15 on Linux, Windows and macOS. These versions and OS families are declared in pyproject.toml's classifiers. CI selects current hosted-runner patch releases within each minor. requires-python >=3.11.5 is an installation floor, not a promise that an unlisted future interpreter or alternative Python implementation is qualified. Adding one requires a reviewed metadata, CI and documentation change. Python 3.10 reached end of life in October 2026 and is no longer supported. Every supported interpreter provides the standard-library tomllib, so the SDK has no TOML backport dependency.
| Lane | Required combinations | What it proves |
|---|---|---|
sdk-compatibility core contracts | Pushes and full-ci pull requests: all five versions × ubuntu-latest, windows-latest, macos-latest (15 jobs). Other pull requests: Linux 3.11 and 3.15, Windows 3.15 and macOS 3.15 (4 jobs) | Privacy sentinels, full traceback rendering, platform filesystem contracts and smoke-runner negative tests |
sdk-compatibility installed artifacts | The same jobs; both wheel and sdist; core and [cli,service,mcp] installs separately | Installed CLI and brief API/adapters, packaged resources, missing-resource rejection and source-tree isolation |
| Optional-runtime absence | Both install profiles in every compatibility job | Typed missing-MLX error and fail-closed brief; no cloud fallback, weights or model downloads |
test full regression | Pushes and full-ci pull requests: Linux, Windows and macOS 3.11–3.12 | The complete Python regression suite, including the slow and fuzz tiers |
test pull-request tier | Linux 3.11 and 3.12 (fast tier); Windows and macOS 3.12 (portability checks) | Every test except slow and fuzz on Linux, plus the platform-sensitive portability list on Windows and macOS |
Python 3.14 support covers what this lane installs: the core package and the dev, cli, service and mcp extras. Every package uv.lock pins for those installs ships a CPython 3.14 or pure-Python wheel for Linux x86-64, Windows x64 and macOS arm64. The one exception is jieba, which is published only as a pure-Python source distribution for every interpreter. So uv sync --frozen --python 3.14 needs no compiled source build there. Other optional extras, such as model runtimes, OCR engines, MLX and Core ML, are not exercised on 3.14 by this lane and are not claimed as qualified on it.
Python 3.15¶
Python 3.15 support covers the same installs as 3.14: the core package and the dev, cli, service and mcp extras, which the sdk-compatibility lane installs and tests on Linux, Windows and macOS. The versions uv.lock pins for 3.11 to 3.14 mostly publish no CPython 3.15 wheels, so pyproject.toml adds 3.15-only lower bounds ([tool.uv] constraint-dependencies entries marked python_version >= '3.15'). Only the 3.15 resolution fork moves; the 3.11 to 3.14 resolutions are unchanged. On 3.15 that fork brings newer major versions of some dependencies, notably pandas 3, pyarrow 26 and, in dev and the duckdb extra, duckdb 2.
pyyaml, a core dependency, publishes no 3.15 wheel yet (yaml/pyyaml#981). Installers build it from its source distribution: with a C compiler and libyaml they build the C extension, and otherwise they install PyYAML's pure-Python implementation. jieba is a pure-Python source distribution on every interpreter.
These requirements are excluded on 3.15 with a python_version < '3.15' marker, because no release installs there:
| Extra | Excluded on 3.15 | Why |
|---|---|---|
dev, zh | opencc | No 3.15 wheel and no upstream tracking issue (OpenCC on PyPI). Chinese script conversion then returns text unchanged with OpenCCUnavailableWarning |
dev | grpcio-tools | Its first release with 3.15 wheels (1.84) requires protobuf 7, and the service extra pins protobuf below 7. gRPC at runtime is unaffected. Regenerating stubs (make grpc-proto) and the stub-drift test test_grpc_generated_stubs_are_current need 3.14 or older |
beam | apache-beam | Every release caps numpy below 2.5, and numpy first ships 3.15 wheels in 2.5.2 (apache/beam#40249) |
openvino | nncf | Every release caps numpy below 2.5 (NNCF on PyPI) |
scispacy | scispacy | scispacy 0.6 requires numpy below 2 (allenai/scispacy#536) |
Every other optional extra resolves on 3.15 but, as on 3.14, is not exercised by this lane and is not claimed as qualified on it. Several, including the PyTorch-based model runtimes, still have no 3.15 wheels at their locked versions. The full regression suite (test) runs on 3.11 and 3.12 only.
Adding the full-ci label starts a new full CI run. Other label additions do not start CI jobs or cancel the active PR run. Those skipped label events use their own concurrency group; commits and full-ci requests still supersede older CI for the same PR.
The stable sdk-compatibility-gate requires every compatibility job in the run to succeed and is a dependency of the existing build gate. Failed, skipped or cancelled matrix execution cannot count as passing. Jobs run independently (fail-fast: false) with a 25-minute limit. The matrix uses standard hosted-runner hardware; it does not qualify every processor architecture, Windows ACL policy, GPU or optional native backend.
Successful core installation does not imply optional model-runtime support. MLX/Core ML execution needs supported Apple hardware and its declared extras; other native adapters have their own runtime requirements. Runtime-specific integration/model evaluation remains separate from this no-weights SDK gate. An unavailable optional runtime must return its documented typed error/refusal; a core import, CLI, privacy or resource failure is always a broken lane, never a blanket platform skip. No trained checkpoint is a prerequisite for SDK release.
See offline install smoke checks for the exact local artifact commands, synthetic-provider boundaries and value-free JSON reports.
Free-threaded CPython 3.14t: experimental, core only¶
Free-threaded CPython (PEP 779) is not a supported configuration yet, and optional extras are not tested on it. The free-threading-smoke job installs only the core package from the frozen lock on Linux 3.14t and runs scripts/release/free_threading_smoke.py --require-free-threaded. The script:
- imports
openmedand reports whether the GIL is still disabled, plus the first module that re-enabled it. CPython re-enables the GIL when it loads an extension module that has not declared free-threading support; - runs
safety_sweep()on synthetic notes from 4 threads at once and compares every result with a single-threaded baseline.
A crash or any threaded result that differs from the baseline fails the job. A GIL re-enabled at import is reported as a warning annotation, not a failure, because the results are still correct with the GIL on. The only non-standard- library extension module the core import loads is PyYAML's yaml._yaml, so it is the module to check first when the job warns. The uploaded free-threading-smoke.json report holds the interpreter version, GIL states, module names, counts and a digest of offsets and labels only, never input text. Run it locally with python scripts/release/free_threading_smoke.py --report report.json on any interpreter. On a build with the GIL it still checks thread-safety of the results.
Test taxonomy¶
| Marker | Location | Purpose |
|---|---|---|
unit (default) | tests/unit/** | Fast validation of model registry helpers, config utilities, and core APIs. |
integration | opt-in | Exercises multi-component flows (e.g., pipeline creation + formatter). |
slow | any | Resource-scaling, cross-process, subprocess end-to-end and package-wide scan tests. Skipped on pull requests; run on pushes to master and on pull requests labelled full-ci. |
fuzz | any | Hypothesis property tests. Same schedule as slow. |
Configure these markers via pytest.ini entries in pyproject.toml.
Running the suite¶
Git preserves LF line endings for text files on every platform through .gitattributes. This keeps digest-pinned assets and generated test fixtures byte-identical in Windows source checkouts.
uv pip install ".[dev,hf]"
make lint
make format-check
make lint-swift # for Swift/OpenMedKit changes
pytest # fast unit/integration mix
pytest -n auto -m "not slow and not fuzz" # what a pull request runs
pytest -n auto # the full suite
pytest -m slow # only long-running cases
Keeping the suite fast and stable¶
- Mark a test
@pytest.mark.slowwhen it measures memory or scaling, starts a fresh interpreter or CLI subprocess, builds git repositories, or scans the whole package. Pull requests skip it;masterruns it on every push. - Do not assert wall-clock durations. Shared runners vary too much for timing thresholds to say anything about a regression.
- Do not pin exact byte sizes, digests of incidental output, or the versions currently in
uv.lock. The dependency and size gates enforce those; a unit test that repeats them only fails on unrelated changes. - Build expensive fixtures once (module or session scope, or a cached template that each test copies) instead of rebuilding them per case.
- Sweep a data table (every locale, command or vector) inside one test with the
subtestsfixture rather than one parametrized case per row. Each row is still reported on failure, and collection stays small.
For zero-shot smoke checks:
tests/run-tests.sh stitches together lint, format checks, unit tests, and slow smoke checks. Use it as the baseline for CI.
Lightweight multimodal CI lane¶
multimodal-tests runs on Linux and macOS with Python 3.11, independently of model backend qualification. Both jobs must succeed before the CI build gate can pass. It executes all of tests/unit/multimodal, the synthetic multimodal release and clinical validation gates, DICOM and DICOM SR eval suites, OCR routing eval tests, and bounded format-parser fuzz targets. It uses synthetic fixtures and runs without datasets or model weights. DocTR, EasyOCR and PaddleOCR adapter contracts use injected fakes.
Install Tesseract (sudo apt-get install tesseract-ocr on Linux or brew install tesseract on macOS), then run from the repository root:
uv sync --frozen --extra dev --python 3.11
.venv/bin/python -m scripts.testing.multimodal_ci --requirements > /tmp/openmed-multimodal-requirements.txt
uv export --frozen --no-default-groups --no-emit-project --no-hashes \
--extra dev --extra multimodal --output-file /tmp/openmed-multimodal-constraints.txt
uv pip install --python .venv/bin/python --only-binary :all: \
--constraint /tmp/openmed-multimodal-constraints.txt \
--requirement /tmp/openmed-multimodal-requirements.txt
make test-multimodal
The requirements command selects fsspec, Jinja2, NumPy, openpyxl, pdfplumber, python-docx, python-pptx, Pillow, piexif, pikepdf, pydicom, pytesseract and markdown-it-py with the exact bounds from pyproject.toml's multimodal extra. It checks each against the release license allow-list. The exported constraints pin direct and transitive versions to the project lockfile. The lane excludes Torch, ONNX, python-doctr, EasyOCR and PaddleOCR; no new dependency extra or license exception is introduced. Do not install the entire multimodal extra for this lane. The --no-sync --offline Make target preserves the installed lightweight dependencies and prevents dependency resolution during testing.
Before collection, every required import and the Tesseract executable must be available. For example, removing pydicom produces exit code 2 and multimodal-ci: missing or unusable required resources: pydicom. The gate also fails any collection-time importorskip or setup/call/teardown skip with multimodal-ci: zero-skip gate failed; skipped reports=N. It has no skip allow-list. Missing resources and gate summaries contain only controlled names and counts, never import exception values or source payloads.
Tests run with offline model flags and blocked outbound sockets in the pytest process. Parser fuzz workers use the existing synthetic corpus and bounded fuzz-default profile (40 examples), without networking or heavy providers. No network is needed after dependency installation. This lane does not qualify model accuracy, clinical safety or platform-specific inference backends.
The enforced budget is 20 minutes per job, including installation, with 10 minutes for tests and a 120-second per-test timeout. These are limits, not measured performance claims. Hosted Linux/macOS durations must be checked on the first CI run; a timeout is a failure and must be investigated rather than converted to a skip. Failures exposed in existing media implementations are follow-up work, outside the lane's CI-wiring boundary.
Service fault-injection matrix¶
tests/faults/ holds a test-only harness that injects disk (ENOSPC, EIO, partial write, fsync failure), clock (skew, forward and backward jumps, monotonic stall), process (kill and restart from a crash image), network (refused, timeout, reset, egress denied), cancellation and corrupted-state (truncated or garbled store files) faults at documented adapter boundaries.
tests/faults/service_fault_plan.jsonis the seeded matrix. It validates againstopenmed/core/schemas/json/service_fault_plan.schema.json; each case names a component, a fault, an injection point, a phase relative to the component's commit point, a trigger (an explicit call or a seeded range) and one documented outcome:no_effect,retryable,quarantined,rolled_backorcommitted_exactly_once.- Every case runs twice. The control run must pass through the seam and reach the component's baseline; the fault run must fire and reach the declared outcome. Cancellation and kill cases can also require that no temp file, orphaned blob or permit is left behind.
- The runner emits a value-free manifest (case IDs and digests, adapter names, states, counts and reason codes) that validates against
service_fault_manifest.schema.json. The same plan and seed always give the same bytes:OPENMED_PROFILE=test python -m tests.faults.runner --output manifest.json. - Master behaviour that misses a documented outcome is recorded in the plan as a
known_gapwith its owning issue, and pinned by anxfail(strict=True)test so the matrix fails as soon as that issue lands. - The harness never ships in the wheel. It refuses to import when
OPENMED_PROFILE=prodand arms only underOPENMED_PROFILE=test. No environment variable, config key or endpoint can turn a fault on.
To cover a new component, register an adapter in tests/faults/scenarios.py (its commit point, supported fault and injection-point pairs, and baseline outcome), then add cases to the plan. The seams, runner and manifest are shared.
Declared environment settings¶
tests/unit/core/test_settings_declared.py fails when code under openmed/ reads an OPENMED_* environment variable that openmed/core/settings.schema.json does not declare. An offline AST scan resolves os.environ[...], os.environ.get, os.getenv and the package's environment helper wrappers to literal names, and every other whole-string OPENMED_* identifier must be declared as well. The failure names each variable with its path:line and never prints a value.
To add a setting, declare it in the schema with its type, default, bounds, x-secret flag and owning module, then regenerate the reference page with python scripts/docs/render_settings_reference.py. A constant that only looks like an environment variable, such as a FHIR system name or an error code, goes in the schema's x-excluded-identifiers with a reason. A key built at runtime (f-string, concatenation or format) cannot be checked and needs a reasoned dynamic entry in tests/fixtures/settings_undeclared_allowlist.json. Every section is declared now, so the allowlist is empty and ALLOWLIST_CEILING is 0; the allowlist only shrinks.
Docs & API checks¶
- Add
uv run mkdocs build --strictto your CI to fail on missing nav entries, duplicate anchors, or broken markdown. - Add a lightweight API smoke test to ensure packaging and extras stay in sync:
from openmed import analyze_text
result = analyze_text("QA ping", model_name="disease_detection_superclinical")
assert result.entities is not None
Coverage ideas¶
When adding new features, consider tests for:
- Model registry entries (ensuring new keys appear in
list_model_categories). - Public API options and default behaviors.
- Formatter behaviours (HTML/CSS attributes, metadata propagation).
- Zero-shot adapters (BIO/BILOU conversions).
Following this checklist keeps the docs accurate and the automation pipelines green.