Skip to main content

High Performance Test Engine - Rust + Python

Project description

TurboPlex (tpx) — Fast Test Orchestration for Python (Rust core)

English | Español

Rust Python License

TurboPlex is a hybrid Rust + Python test runner that accelerates large suites with:

  • fast test discovery
  • parallel execution
  • SHA-based caching
  • structured JSON reports for IDEs and AI agents

TL;DR

pip install turboplex
tpx --path tests/

Contents

Why TurboPlex?

TurboPlex focuses on making “run tests” fast and machine-consumable:

Feature What you get
Fast discovery AST-based collection avoids heavy imports where possible
Parallel execution Isolated Python subprocess per test (or pytest in compat mode)
Smart caching Cache pass results keyed by file hash + runtime fingerprint
Structured output Stable JSON schema for tooling, MCP, and analysis
Watch mode Rerun suite on file save

Installation

From PyPI:

pip install turboplex
tpx --help

From source (dev):

git clone https://github.com/IzumiKeita/turboplex.git
cd turboplex
pip install -e .
tpx --help

Quick Start

Run a directory:

tpx --path tests/

Run multiple paths:

tpx --path tests/ --path tests/integration/

Auto-discover:

tpx

Watch mode:

tpx --watch --path tests/

Modes

Native mode (default)

Best for suites where:

  • imports can be expensive (DB bootstraps, migrations, Pydantic config)
  • you want faster iteration with caching and structured results

Pytest compatibility mode (--compat)

Use this when you need full pytest semantics/plugins:

tpx --compat --path tests/

Light collect (--light)

Skips conftest.py import during discovery. Useful when conftest.py performs heavy work on import.

tpx --compat --light

Environment alternative:

export TPX_MCP_LIGHT_COLLECT=1  # Linux/Mac
set TPX_MCP_LIGHT_COLLECT=1     # Windows

Windows / venv (TPX_PYTHON_EXE)

TurboPlex resolves the Python interpreter using this precedence:

  1. TPX_PYTHON_EXE (if set and path exists)
  2. python.interpreter from turbo_config.toml (if set and path exists)
  3. Auto-detected .venv/venv/.env/env near the project
  4. System python

Example (force a secondary venv):

$env:TPX_PYTHON_EXE = (Resolve-Path .\.venv_alt\Scripts\python.exe).Path
tpx --path tests/

CLI prints a confirmation line:

  • Using TPX_PYTHON_EXE: C:\path\to\.venv_alt\Scripts\python.exe

Skipping tests (pytest.skip)

In native mode, pytest.skip(...) is recognized and reported as a skip (not a failure):

  • CLI prints SKIP ... lines
  • summary includes skipped
  • JSON includes skipped: true and skip_reason

Example summary:

Results: 120 passed, 0 failed, 5 skipped (24000ms)

Reports

TurboPlex generates machine-readable artifacts:

  • .tplex_report.json and timestamped .tplex_report_%Y%m%d_%H%M%S.json
  • turboplex_full_report.json (JSONL) with richer error context for large suites

Cache

Cache lives in .turboplex_cache/ and is invalidated when:

  • test files change (hash)
  • runtime fingerprint changes (Python version, deps hash, PYTHONPATH, flags)

MCP server (IDE integration)

Start the MCP server:

tpx mcp

Notes:

  • --out-json avoids stdout pollution for JSON-RPC toolchains.
  • subprocesses force UTF-8 (PYTHONUTF8=1, PYTHONIOENCODING=utf-8, PYTHONUNBUFFERED=1).

Common MCP env vars:

  • TPX_PYTHON_EXE
  • TPX_MCP_LIGHT_COLLECT=1
  • TPX_MCP_DEBUG=1
  • TPX_MCP_STDOUT_MODE=redirect|failfast
  • TPX_MCP_TEST_TIMEOUT_S (default 120)
  • TPX_MCP_TURBOPLEX_COLLECT_TIMEOUT_S (default 120)
  • TPX_MCP_TURBOPLEX_RUN_TIMEOUT_S (default 60)
  • TPX_MCP_PYTEST_COLLECT_TIMEOUT_S / TPX_PYTEST_COLLECT_TIMEOUT_S (default 120)
  • TPX_MCP_PYTEST_RUN_TIMEOUT_S / TPX_PYTEST_RUN_TIMEOUT_S (default 60)
  • TPX_MCP_HEARTBEAT_S (default 1)
  • TPX_MCP_TERMINATE_GRACE_S (default 2)
  • TPX_MCP_DRAIN_MAX_CHARS (default 2000000)
  • TPX_MCP_LOGS_MAX_CHARS (default 20000)

Error contract (ok=false):

  • data.error.code in timeout | subprocess_failed | invalid_input | not_found | internal_error
  • data.error.message is always human-readable
  • data.error.details may include phase, returncode, timeout_s, and truncated stderr/stdout metadata

Tool response shape (discover, run, get_report):

  • top-level: schemaVersion, tool, ok, runId, mode, summary, logs, data
  • run.summary also includes workers_used, timeouts, subprocess_failures
  • DB-first additions:
    • data.results[].db_metrics.write_count
    • data.results[].db_dirty
    • data.results[].db_dirty_summary
    • run.summary.db_write_count_total
    • run.summary.db_dirty_tests

Integration coverage added today:

  • tests/test_mcp_db_integration.py validates MCP run DB metrics with SQLite writes.
  • strict dirty policy verified:
    • TPX_DB_STRICT_DIRTY=0 -> run can pass while reporting db_dirty.
    • TPX_DB_STRICT_DIRTY=1 -> run fails with db_error.code=db_dirty_state.
  • subprocess-only variant added with xfail guard on Windows for occasional native crash 0xC0000005 (Access Violation).

DB hardening env vars:

  • TPX_DB_STRICT_DIRTY=0|1 (default 0, fail test only when dirty + strict enabled)
  • TPX_DB_METRICS_ENABLED=0|1 (default 1)
  • TPX_DB_ISOLATION_MODE=auto|schema|database|transaction (default auto)
  • TPX_DB_WORKER_PREFIX=tpx_w
  • TPX_DB_DIRTY_TRACK_MAX_TABLES=12

Example MCP config:

{
  "mcpServers": {
    "tpx": {
      "command": "tpx",
      "args": ["mcp"],
      "env": {
        "TPX_PYTHON_EXE": "/path/to/venv/bin/python",
        "TPX_MCP_LIGHT_COLLECT": "1",
        "TPX_MCP_DEBUG": "1"
      }
    }
  }
}

Configuration

turbo_config.toml example:

[execution]
max_workers = 8
default_timeout_ms = 30000
cache_enabled = true

[python]
enabled = true
interpreter = "python"
module = "turboplex_py"
test_paths = ["tests"]
project_path = "."

Benchmarks

Production suite (~200 tests):

Tool Time per test
pytest ~340s ~1.7s
tpx (cold) ~180s ~0.9s
tpx (cached) ~25s ~0.13s

Troubleshooting

Common issues:

  • “Fixture not found” in native mode
    • Use --compat if you rely on complex pytest fixtures/plugins
  • Slow discovery
    • Use --light (or TPX_MCP_LIGHT_COLLECT=1) to avoid heavy conftest imports
  • “ModuleNotFoundError” during run
    • Ensure your project is on PYTHONPATH or configured via turbo_config.toml

Development

Build wheels with maturin:

python -m pip install maturin
python -m maturin build --release -o dist
python -m maturin sdist -o dist

License

MIT License — see LICENSE

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

turboplex-0.3.3.tar.gz (3.0 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

turboplex-0.3.3-py3-none-win_amd64.whl (947.0 kB view details)

Uploaded Python 3Windows x86-64

File details

Details for the file turboplex-0.3.3.tar.gz.

File metadata

  • Download URL: turboplex-0.3.3.tar.gz
  • Upload date:
  • Size: 3.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.12.6

File hashes

Hashes for turboplex-0.3.3.tar.gz
Algorithm Hash digest
SHA256 d95c992229f6d8edbb491c6674108fa4db535204b38b6d392cb209ca229f3dac
MD5 4ed08e11d65153ca181b2a728a7db4d6
BLAKE2b-256 78d71b53ac3603d61f27b6fd3445d0e7d49a9b81a9fc7714f1d58bc6daf4ec48

See more details on using hashes here.

File details

Details for the file turboplex-0.3.3-py3-none-win_amd64.whl.

File metadata

  • Download URL: turboplex-0.3.3-py3-none-win_amd64.whl
  • Upload date:
  • Size: 947.0 kB
  • Tags: Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.12.6

File hashes

Hashes for turboplex-0.3.3-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 192fbf4dbcce9e741b9dd5858e45a87a81d9ff40d3ee7f1a2c56cd183c57134d
MD5 6df56860a2e37242425aec13f94bbc75
BLAKE2b-256 f7651f88ff135f017da6b98044ae1f2f7ba589dd50b7197481072f8d171a816a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page