CLI Reference¶
Complete reference for all rpytest command-line options.
Synopsis¶
Test Selection¶
Paths¶
rpytest # Run all tests
rpytest tests/ # Run tests in directory
rpytest tests/test_auth.py # Run specific file
rpytest tests/test_auth.py::test_login # Run specific test
rpytest tests/test_auth.py::TestClass::test_method # Run class method
-k, --keyword EXPR¶
Select tests by keyword expression.
rpytest -k auth # Tests containing "auth"
rpytest -k "auth and login" # Tests containing both
rpytest -k "auth or signup" # Tests containing either
rpytest -k "not slow" # Tests NOT containing "slow"
rpytest -k "auth and not integration" # Combined
-m, --marker EXPR¶
Select tests by marker expression.
rpytest -m slow # Tests marked @pytest.mark.slow
rpytest -m "not slow" # Tests NOT marked slow
rpytest -m "smoke and not flaky" # Combined markers
Execution Control¶
-x, --exitfirst¶
Exit on first failure.
--maxfail N¶
Exit after N failures.
-n, --workers N¶
Number of parallel workers.
rpytest -n 4 # 4 workers
rpytest -n auto # Auto-detect CPUs
rpytest -n 1 # Sequential (single worker)
--lf, --last-failed¶
Run only tests that failed in the last run.
--ff, --failed-first¶
Run failed tests first, then the rest.
--nf, --new-first¶
Run new tests first, then the rest.
Output Control¶
-v, --verbose¶
Increase verbosity. Can be repeated.
-q, --quiet¶
Decrease verbosity. Can be repeated.
--tb STYLE¶
Traceback print mode.
| Style | Description |
|---|---|
auto |
Default, short for many failures |
long |
Full traceback |
short |
Shorter traceback |
line |
Single line per failure |
native |
Python standard traceback |
no |
No traceback |
--no-header¶
Don't show the rpytest header.
-l, --showlocals¶
Show local variables in tracebacks.
-r CHARS¶
Show summary for specified test outcomes.
| Char | Meaning |
|---|---|
f |
Failed |
E |
Error |
s |
Skipped |
x |
Xfailed |
X |
Xpassed |
p |
Passed |
a |
All except passed |
--durations N¶
Show N slowest test durations.
--durations-min SECS¶
Minimum duration to include in slowest list.
Collection¶
--collect-only, --co¶
Only collect tests, don't run them.
--ignore PATH¶
Ignore a path during collection.
--ignore-glob PATTERN¶
Ignore paths matching glob pattern.
Configuration¶
-c, --config-file FILE¶
Load configuration from specific file.
--rootdir DIR¶
Set root directory for test discovery.
-o, --override-ini OPTION=VALUE¶
Override ini configuration option.
Output Formats¶
--json¶
Output machine-readable JSON format.
--junitxml PATH¶
Create JUnit XML report.
Capture¶
--capture, -s METHOD¶
Per-test capturing method.
| Method | Description |
|---|---|
fd |
File descriptor level (default) |
sys |
sys.stdout/stderr level |
no |
No capturing |
tee-sys |
Capture and also output |
Debugging¶
--pdb¶
Start debugger on errors.
--trace¶
Start debugger at test start.
Flakiness & Rerun¶
--reruns N¶
Rerun failed tests up to N times.
--reruns-delay MS¶
Delay between reruns in milliseconds.
--only-rerun-flaky¶
Only rerun tests known to be flaky.
--flaky-report¶
Show flakiness report after run.
Sharding¶
--shard INDEX¶
Run only tests in shard INDEX (0-indexed).
--total-shards N¶
Total number of shards.
--shard-strategy STRATEGY¶
Sharding strategy.
| Strategy | Description |
|---|---|
hash |
Consistent hash-based |
round_robin |
Round-robin distribution |
duration_balanced |
Balance by test duration (default) |
Fixture Reuse¶
--reuse-fixtures¶
Enable session fixture reuse between runs.
--fixture-max-age SECS¶
Maximum age for reused fixtures (default: 600).
Daemon Management¶
--daemon¶
Run as daemon (foreground mode).
--daemon-status¶
Show daemon status.
--daemon-stop¶
Stop the running daemon.
--daemon-idle-timeout SECS¶
Daemon idle timeout (default: 300).
--cleanup¶
Clean up stale test contexts.
--cleanup-max-age SECS¶
Maximum age for cleanup (default: 3600).
rpytest Extensions¶
--watch¶
Watch mode: re-run tests on file changes.
--verify-dropin¶
Verify drop-in compatibility with pytest.
--inventory-status¶
Show test inventory status.
-V, --version¶
Show version.
Passthrough Arguments¶
Arguments after -- are passed to the daemon/plugins:
Environment Variables¶
| Variable | Description |
|---|---|
VIRTUAL_ENV |
Virtual environment path |
PYTHON |
Python interpreter path |
XDG_RUNTIME_DIR |
Runtime directory for socket |
RPYTEST_LOG |
Log level (debug, info, warn) |