Sandboxed pytest stalls when run via make or redirected output, but direct foreground pytest works
Summary
I found a narrower sandbox-related pytest reproduction than the existing timeout reports.
In my environment, Python/pytest itself is not generally broken inside the Codex sandbox. The failure mode is more specific:
- works inside sandbox:
source .venv/bin/activate && python -m pytest -vv- stalls inside sandbox:
make test-backendwhere the recipe is justpython -m pytest -vvpython -m pytest -vv > out.txt 2>&1python -m pytest -vv -s > out.txt 2>&1- works outside sandbox:
make preflightmake test-backend
So the issue seems to be triggered when pytest is not attached to the live foreground exec output path inside the sandbox, rather than pytest being universally sandbox-incompatible.
Environment
- Codex CLI in sandbox mode
- Ubuntu Linux
- Python 3.12.3
- pytest 9.0.2
- bubblewrap-based sandbox (Codex default on Linux)
Reproduction
In a repo with a passing backend test suite:
Works
source .venv/bin/activate && python -m pytest -vv
This streams progress normally and finishes.
Stalls
make test-backend
Where test-backend is effectively:
test-backend:
.venv/bin/python -m pytest -vv
The command starts normally, prints the pytest session header and first test line, then stops making visible progress in the sandbox.
Also stalls
source .venv/bin/activate && python -m pytest -vv > /tmp/out.txt 2>&1
source .venv/bin/activate && python -m pytest -vv -s > /tmp/out.txt 2>&1
Both timed out in the sandbox after reaching the first test line.
What I checked
tests/test_backup.py -vvby itself passes in about 1 second inside the sandbox.- full
python -m pytest -vvpasses inside the sandbox when run directly in the foreground. - a trivial
makerecipe running a streaming Python script works fine in the sandbox, so this is not just “make is broken in sandbox”. - the problematic combination seems to be: pytest + sandbox + non-foreground/non-live-output execution path.
Why this seems distinct from the broader timeout issue
The existing timeout reports made it look like pytest itself was generally broken in sandbox.
This reproduction suggests the bug is narrower:
- direct foreground pytest can work
- pytest stalls when launched through
makeor when stdout/stderr are redirected away from the live foreground session
That points more toward sandboxed exec/session/output handling than pytest compatibility in general.
Request
Can you confirm whether this is a known Codex sandbox/PTY/output-path issue?
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗