Python Test Debugging Cheat Sheet/Print key environment values in a test

Reveal CI-only configuration mismatches.

Section: CI and Flaky Tests

Print key environment values in a test

python
python
import os

def test_env_debug():
    print({k: os.environ.get(k) for k in ['CI', 'APP_ENV', 'DATABASE_URL']})

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing CI and Flaky Tests
Re-run a failing test repeatedly
Loop a single test to reproduce flakiness locally.
OpenIn sheetbashsame section
Run tests matching a keyword
Filter tests by substring expression.
OpenIn sheetbash1 tag match
Show fixture setup order
Trace fixture behavior during a run.
OpenIn sheetbash1 tag match
Run tests by marker
Target a marked test group.
OpenIn sheetbash1 tag match
Show fixture setup plan
Print fixture plan without full execution noise.
OpenIn sheetbash1 tag match
Stop after N failures
Limit noise during triage.
OpenIn sheetbash1 tag match