pytest plugin for testing CAD/BIM API code inside host applications via RevitDevTool Named Pipe bridge
Project description
RevitDevTool.PyTest
pytest plugin for testing CAD/BIM API code inside host applications via RevitDevTool Named Pipe bridge. Supports Revit, AutoCAD-family, and any host exposing a DevToolsPipeServer pipe. Tests run inside a live host process — write standard pytest, execute remotely.
Installation
pip install revitdevtool_pytest
Dependencies
| Package | Version |
|---|---|
| Python | >= 3.10 |
| pytest | >= 9.0 |
| pywin32 | >= 311 |
Requirements
- Windows (Named Pipes)
- A host application with RevitDevTool add-in installed and loaded
Supported Hosts
Pre-registered
| 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 |
navisworks |
Navisworks | Navisworks |
rhino |
Rhino | Rhino |
tekla |
Tekla Structures | Tekla |
Any host
Any host name works — unknown names get a fallback config using the name as pipe prefix. Connect via auto-discovery or --host-pipe.
Pipe Name Format
Pipes follow {Host}_{Version}_{PID} (e.g. Revit_2025_12345, Rhino_8.0_9999). Version can be any format — year, semver, etc.
Project Setup
Recommended: scaffold your project with uv or pixi:
# uv
uv init my-revit-tests
cd my-revit-tests
uv add revitdevtool_pytest
# pixi (uses pyproject.toml as manifest)
pixi init --format pyproject my-revit-tests
cd my-revit-tests
pixi add --pypi revitdevtool_pytest
Configuration
Add plugin settings to [tool.pytest.ini_options] in your pyproject.toml:
[tool.pytest.ini_options]
host_name = "revit"
host_version = "2025"
host_launch = false
host_launch_timeout = "180"
| Option | Type | Default | Description |
|---|---|---|---|
host_name |
string | "revit" |
Host application name (see Supported Hosts above). |
host_version |
string | — | Host version (e.g. "2025", "8.0"). Required when host_launch = true. |
host_launch |
bool | false |
Force-launch a new host instance (skip reusing existing free instances). |
host_timeout |
string | "60" |
Per-test execution timeout in seconds. |
host_launch_timeout |
string | "120" |
Seconds to wait for host to start. |
host_pipe |
string | — | Explicit pipe name (bypasses auto-discovery). |
CLI flags override INI settings:
# Revit
pytest --host-launch --host-version=2025 -v
# AutoCAD
pytest --host autocad --host-version=2026 -v
# Civil 3D
pytest --host civil3d --host-version=2026 -v
Connection Behavior
- Default (
host_launch = false): plugin auto-discovers a running host instance matchinghost_versionvia Named Pipe scan. If none found, exits with error. - Force launch (
host_launch = true): always spawns a new host process, waits for its pipe to appear, then connects. Existing instances are ignored.
Print Output
Captured print() output from tests running inside the host is automatically shown in the terminal for passing tests (equivalent to -rP). No extra flags needed.
Usage
Fixtures
Define fixtures in conftest.py that provide host API objects:
import pytest
# Revit fixtures
@pytest.fixture(scope="session")
def revit_uiapp():
return __revit__ # UIApplication injected by RevitDevTool
@pytest.fixture(scope="session")
def revit_app(revit_uiapp):
return revit_uiapp.Application
@pytest.fixture(scope="session")
def revit_doc(revit_uiapp):
return revit_uiapp.ActiveUIDocument.Document
Writing Tests
def test_active_view(revit_doc):
view = revit_doc.ActiveView
print(f"Active View: {view.Name}")
assert view.Name is not None
def test_revit_version(revit_app):
assert "2025" in revit_app.VersionName
PEP 723 Dependencies
Declare test-suite dependencies in conftest.py using PEP 723 metadata. RevitDevTool auto-installs them before test execution:
# /// script
# dependencies = [
# "numpy>=2.0",
# "polars>=1.0",
# ]
# ///
Running Tests
# With pyproject.toml configured:
pytest
# Override version for a single run:
pytest --host-version=2026 -v
# Target a different host:
pytest --host autocad --host-version=2026 -v
# Using uv or pixi:
uv run pytest
pixi run pytest
How It Works
- pytest discovers and collects tests locally
- Plugin intercepts
pytest_runtestloop, connects to the host via Named Pipe - Test nodeids are sent to the host's
PytestRunner.py(embedded in RevitDevTool) - Tests execute inside the host's Python.NET environment with full API access
- Results (pass/fail/skip, stdout, stderr, tracebacks) are returned via pipe
- Plugin maps results back to standard pytest reports
IDE Integration
VS Code / Cursor
{
"python.testing.pytestEnabled": true,
"python.testing.pytestArgs": ["tests"]
}
PyCharm
Enable pytest as the test runner. Plugin auto-detects IDE adapters and disables streaming to avoid duplicate results in the test tree.
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
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.3.0.tar.gz.
File metadata
- Download URL: revitdevtool_pytest-0.3.0.tar.gz
- Upload date:
- Size: 65.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
98bfc10198e6957adc55e9cf936f32187ac259fb51ea5717775817c510d6d971
|
|
| MD5 |
ae047f82c7a6253d30c163a721b22a4f
|
|
| BLAKE2b-256 |
d793b97ba04fc921783fde9d1560ed3a696fde7379d5699ab2333d9cdf645234
|
Provenance
The following attestation bundles were made for revitdevtool_pytest-0.3.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.3.0.tar.gz -
Subject digest:
98bfc10198e6957adc55e9cf936f32187ac259fb51ea5717775817c510d6d971 - Sigstore transparency entry: 1684015586
- Sigstore integration time:
-
Permalink:
trgiangv/RevitDevTool.PyTest@dbe5ca1e564b48d5ebee6506a1ad1f1871b593fc -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/trgiangv
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@dbe5ca1e564b48d5ebee6506a1ad1f1871b593fc -
Trigger Event:
release
-
Statement type:
File details
Details for the file revitdevtool_pytest-0.3.0-py3-none-any.whl.
File metadata
- Download URL: revitdevtool_pytest-0.3.0-py3-none-any.whl
- Upload date:
- Size: 27.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7079e334163f569b6da5e9cbce61e55ae67a447d4f1f6eb17d26c684d47bc0d1
|
|
| MD5 |
43646adc34db3f48559e702c68d46013
|
|
| BLAKE2b-256 |
5b620329b480b54768963deb465de265cab8ca491fa016f0b708d82a60bdab01
|
Provenance
The following attestation bundles were made for revitdevtool_pytest-0.3.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.3.0-py3-none-any.whl -
Subject digest:
7079e334163f569b6da5e9cbce61e55ae67a447d4f1f6eb17d26c684d47bc0d1 - Sigstore transparency entry: 1684015856
- Sigstore integration time:
-
Permalink:
trgiangv/RevitDevTool.PyTest@dbe5ca1e564b48d5ebee6506a1ad1f1871b593fc -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/trgiangv
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@dbe5ca1e564b48d5ebee6506a1ad1f1871b593fc -
Trigger Event:
release
-
Statement type: