RevitDevTool.PyTest
pytest plugin for testing CAD/BIM API code inside live host applications via the RevitDevTool Named Pipe bridge.
Write tests locally with pytest; execution happens inside the host process. Currently supported: Revit and AutoCAD family only. Navisworks, Rhino, Tekla, and other hosts are in progress.
Installation
pip install revitdevtool_pytest
# or
uv add revitdevtool_pytest
| Requirement | Version |
|---|---|
| Python | >= 3.10 |
| pytest | >= 9.0 |
| pywin32 | >= 311 |
| OS | Windows (Named Pipes) |
| Host | RevitDevTool add-in loaded |
Supported hosts
Supported today
host_name |
Application | Pipe prefix |
|---|---|---|
revit |
Autodesk Revit | Revit |
autocad |
AutoCAD | AutoCad |
civil3d |
Civil 3D | Civil3D |
plant3d |
Plant 3D | Plant3D |
acadarch |
AutoCAD Architecture | AcadArch |
acadmech |
AutoCAD Mechanical | AcadMech |
acadmep |
AutoCAD MEP | AcadMep |
acadelec |
AutoCAD Electrical | AcadElec |
acadmap3d |
AutoCAD Map 3D | AcadMap3D |
In progress
host_name |
Application | Status |
|---|---|---|
navisworks |
Navisworks | Not validated |
rhino |
Rhino | Not validated |
tekla |
Tekla Structures | Not validated |
The plugin registry may list additional names for future work. Treat them as experimental until documented here as Supported today.
Pipe names (pytest only)
The plugin connects to the pytest/control pipe:
DevTools_{Host}_{Version}_{PID}
Examples: DevTools_Revit_2025_12345, DevTools_AutoCad_2026_7890
MCP clients use a separate pipe: DevToolsMcp_{Host}_{Version}_{PID}. Do not point pytest at an MCP pipe.
Quick start (consumer project)
uv init my-host-tests && cd my-host-tests
uv add revitdevtool_pytest pytest
pyproject.toml:
[tool.pytest.ini_options]
host_name = "revit"
host_version = "2025"
force_launch = false
per_test_timeout = "60"
launch_timeout = "180"
tests/conftest.py:
import pytest
@pytest.fixture(scope="session")
def revit_uiapp():
return __revit__
@pytest.fixture(scope="session")
def revit_doc(revit_uiapp):
return revit_uiapp.ActiveUIDocument.Document
tests/test_smoke.py:
def test_active_view(revit_doc):
assert revit_doc.ActiveView is not None
uv run pytest -v
Configuration
| Option | Default | Description |
|---|---|---|
host_name |
"revit" |
Target host — use Supported today names only. |
host_version |
— | Version string ("2025", "8.0", …). Required for launch. |
force_launch |
false |
Force a new host instance (skip reuse). Requires host_version. |
per_test_timeout |
"60" |
Per-test budget (seconds). The tests/run pipe wait is this × collected tests. |
launch_timeout |
"180" |
Wait for host pipe after launch (seconds). |
host_pipe |
— | Explicit pipe name (skip discovery). |
CLI flags override INI: --host, --host-version, --force-launch, --per-test-timeout, --launch-timeout, --host-pipe.
Connection behavior
force_launch = false(default): scan forDevTools_*pipes matchinghost_name/host_version, reuse a free instance (suite leasing), or reconnect to a leased PID.- No matching instance: auto-launch host when
host_versionis set (unless--host-pipepins an existing pipe). force_launch = true: always spawn a new process and wait for its pipe.
Print output
Captured print() from in-host tests is shown for passing tests (same as -rP). No extra flags needed.
Writing tests
- Put host API imports inside functions — collection runs on your machine, execution in the host.
- Use fixtures for
__revit__, documents, and rollback helpers. - Declare suite dependencies with PEP 723 in CPython
conftest.py(ortest_*.py); RevitDevTool installs them beforetests/run. IronPythontest_*_ipy.pydoes not use PEP 723 —ipytests/runnever installs packages.
# /// script
# dependencies = ["numpy>=2.0", "polars>=1.0"]
# ///
Revit rollback fixture
@pytest.fixture
def revit_auto_rollback(revit_transaction_service):
revit_transaction_service.StartChanges()
try:
yield revit_transaction_service
finally:
revit_transaction_service.RevertChanges()
How it works
- Local pytest collects tests.
- Plugin connects to
DevTools_{Host}_{Version}_{PID}. - Node IDs sent via JSON-RPC method
tests/run(BridgeMessagelength-prefixed frames). - Host runs
PytestRunner.pyembedded in RevitDevTool (PytestExecutionServiceon main thread). - Results and optional progress notifications return to the client.
- Plugin maps
CaseResult→ standard pytest reports.
Developing this repository
Clone and run integration tests against a live host:
cd RevitDevTool.PyTest
uv run pytest -v # Revit suite (default)
uv run pytest tests/Revit/test_smoke.py -v
uv run pytest --host civil3d --host-version 2026 # after switching testpaths/host in pyproject.toml
Layout
| Path | Purpose |
|---|---|
src/revitdevtool_pytest/ |
Plugin source (published wheel) |
tests/Revit/ |
Revit integration tests + schedule/ helpers |
tests/Civil3d/ |
Civil 3D / AutoCAD API tests |
Revit suite settings in pyproject.toml: testpaths = ["tests/Revit"], pythonpath = ["tests/Revit"] for local schedule imports.
Optional env: REVIT_TEST_MODEL_PATH — path to .rvt for revit_doc fixture (default F:\Project1.rvt).
IDE integration
VS Code / Cursor — python.testing.pytestEnabled: true. Plugin detects vscode_pytest / TEST_RUN_PIPE and disables CLI streaming to avoid duplicate tree entries.
PyCharm — enable pytest as test runner.
License
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file revitdevtool_pytest-0.4.0.tar.gz.
File metadata
- Download URL: revitdevtool_pytest-0.4.0.tar.gz
- Upload date:
- Size: 73.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
88ccaa1a7b2f4cb4590793928ab9f9ed6397600b051768fb85c360fd73d8098a
|
|
| MD5 |
3c28686784b318a0045e5220bfb70814
|
|
| BLAKE2b-256 |
85b5662e3ff53322f5c9363438f050016ad804fae146027f212b43e5428a468b
|
Provenance
The following attestation bundles were made for revitdevtool_pytest-0.4.0.tar.gz:
Publisher:
publish.yml on trgiangv/RevitDevTool.PyTest
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
revitdevtool_pytest-0.4.0.tar.gz -
Subject digest:
88ccaa1a7b2f4cb4590793928ab9f9ed6397600b051768fb85c360fd73d8098a - Sigstore transparency entry: 2714453921
- Sigstore integration time:
-
Permalink:
trgiangv/RevitDevTool.PyTest@9a36c057021abab5d7ea9550e88aa4b85e6c1544 -
Branch / Tag:
refs/tags/v0.4.0 - Owner: https://github.com/trgiangv
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@9a36c057021abab5d7ea9550e88aa4b85e6c1544 -
Trigger Event:
release
-
Statement type:
File details
Details for the file revitdevtool_pytest-0.4.0-py3-none-any.whl.
File metadata
- Download URL: revitdevtool_pytest-0.4.0-py3-none-any.whl
- Upload date:
- Size: 30.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dcc5c682b17b8935eaefd3221c5077eb39159736c2d29fff1625e341c6f6556f
|
|
| MD5 |
8e1856195501a8bcae9215ae7acc0717
|
|
| BLAKE2b-256 |
4c8d88f32b479d88adf51ea9e139eb064c1785c4224cf437372dd17705a35936
|
Provenance
The following attestation bundles were made for revitdevtool_pytest-0.4.0-py3-none-any.whl:
Publisher:
publish.yml on trgiangv/RevitDevTool.PyTest
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
revitdevtool_pytest-0.4.0-py3-none-any.whl -
Subject digest:
dcc5c682b17b8935eaefd3221c5077eb39159736c2d29fff1625e341c6f6556f - Sigstore transparency entry: 2714453934
- Sigstore integration time:
-
Permalink:
trgiangv/RevitDevTool.PyTest@9a36c057021abab5d7ea9550e88aa4b85e6c1544 -
Branch / Tag:
refs/tags/v0.4.0 - Owner: https://github.com/trgiangv
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@9a36c057021abab5d7ea9550e88aa4b85e6c1544 -
Trigger Event:
release
-
Statement type: