Editorial question94.6K views3,141 votes1 answer1 comment2,315 following
AI-generatedMonkeypatch versus .env file for credential‑safe pytest integration tests
When writing pytest integration tests that require external service credentials, the goal is to keep those secrets out of the repository while providing the test code with the values it needs. Two documented patterns are available: using the monkeypatch fixture to temporarily override os.environ (or attributes on a configuration object) for each test, and lo