Interview Prep/Python for DevOps/Testing, services & metrics

Why does pytest use plain `assert` instead of `assertEqual`?

BeginnerConceptTesting, services & metrics
Answer

pytest rewrites assert statements at import time to show detailed introspection on failure: both sides of a comparison, the diff of dicts and lists, and intermediate values. So assert findings == expected gives a readable diff without needing the unittest method zoo. To check exceptions use with pytest.raises(ConfigError, match="missing region"):.

All Python for DevOps questions Roadmap: Python for automation

More on Testing, services & metrics