pytest Plugin¶
Dolphin registers a pytest plugin automatically through the pytest11 package entry point. Install dolphin-desktop in the same environment as pytest; no import is required in conftest.py.
Fixtures¶
desktop¶
Session-scoped Desktop instance. The backend comes from --dolphin-backend.
launch¶
Function-scoped helper. It calls Desktop.launch(...), records the returned Application, and calls Application.kill() during teardown.
launch accepts the same keyword arguments as Desktop.launch:
def test_with_args(launch):
app = launch("myapp.exe", timeout=20, startup_delay=1.0)
win = app.window(title="My App")
dolphin_backend¶
Session-scoped value of --dolphin-backend.
dolphin_timeout¶
Session-scoped effective timeout from CLI, environment, or the default.
dolphin_headless¶
Session-scoped flag set by --dolphin-headless or DOLPHIN_HEADLESS=1.
CLI Options¶
| Option | Default | Description |
|---|---|---|
--dolphin-backend {uia,win32} |
uia |
pywinauto backend |
--dolphin-timeout FLOAT |
10.0 |
Default element wait timeout in seconds |
--dolphin-screenshot-on-fail |
off | Capture a full-screen PNG on test failure |
--dolphin-headless |
off | Create Desktop(hidden=True) through the fixture |
--dolphin-trace {off,on-failure,always} |
on-failure |
Trace capture mode |
--dolphin-trace-dir PATH |
dolphin-traces |
Trace output directory |
--dolphin-video {off,keepfailedonly,keepall} |
keepfailedonly |
Video capture mode |
--dolphin-video-dir PATH |
dolphin-videos |
Video output directory |
--dolphin-html PATH |
automatic | Fallback HTML report path |
--dolphin-log-level {DEBUG,INFO,ERROR} |
INFO |
Dolphin log verbosity |
--dolphin-retry N |
0 |
Retry transient ElementNotFoundError and WaitTimeoutError failures |
Examples:
pytest tests/ -v --dolphin-backend=win32
pytest tests/ -v --dolphin-timeout=20
pytest tests/ -v --dolphin-screenshot-on-fail
pytest tests/ -v --dolphin-trace=always
pytest tests/ -v --dolphin-video=keepfailedonly
Environment Variables¶
| Variable | Default | Description |
|---|---|---|
DOLPHIN_TIMEOUT |
10.0 |
Default element wait timeout |
DOLPHIN_TRACE |
on-failure |
Trace mode: always, on-failure, off |
DOLPHIN_VIDEO |
keepfailedonly |
Video mode: keepall, keepfailedonly, off |
DOLPHIN_VIDEO_FPS |
10 |
Video frame rate |
DOLPHIN_HEADLESS |
0 |
Headless desktop flag |
DOLPHIN_LOG_LEVEL |
INFO |
Logging level |
DOLPHIN_RETRY |
0 |
Retry count for transient Dolphin errors |
DOLPHIN_TELEMETRY |
off |
Telemetry opt-in flag |
Per-Test Marker¶
Use @pytest.mark.dolphin(...) for per-test overrides:
import pytest
@pytest.mark.dolphin(timeout=30, video_mode="keepall")
def test_slow_flow(launch):
app = launch("myapp.exe")
@pytest.mark.dolphin(headless=True) skips the test unless headless mode is active.
Generated Artifacts¶
| Artifact | Default path |
|---|---|
| Screenshots on failure | dolphin-screenshots/ |
| Traces | dolphin-traces/ |
| Videos | dolphin-videos/ |
| Fallback HTML report | dolphin-report.html when Allure is not installed |