# Failed: DID NOT RAISE <class 'SystemExit'>
UNEXPECTED EXCEPTION: SystemExit(0)

- **ID:** `python/pytest-doctest-capture-stdout`
- **Domain:** python
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

A doctest that calls sys.exit() or argparse with --help exits the interpreter; doctest expects a return value, not a process exit.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 7.x | active | — | — |
| 8.x | active | — | — |

## Workarounds

1. **** (90% success)
   ```
   >>> import sys
>>> try:
...     main(["--help"])
... except SystemExit as e:
...     print("exit", e.code)
exit 0
   ```
2. **** (95% success)
   ```
   def main(argv=None) -> int:
    ...
    return 0

if __name__ == "__main__":
    raise SystemExit(main())
   ```

## Dead Ends

- **** — Continues after failure but doesn't prevent SystemExit. (85% fail)
- **** — In doctest source, suppress changes the observable output. (70% fail)
- **** — Hides a real usability bug in the CLI. (80% fail)
