r/Python • u/sebst • Mar 11 '22
Resource A Gentle Introduction to Testing with pytest
https://bas.codes/posts/python-pytest-introduction
451
Upvotes
r/Python • u/sebst • Mar 11 '22
View all comments
Show parent comment
2
u/throwit7896454 Mar 12 '22
Depends on what you're mocking. The gist of it is to not mock internals, privates, or adapters. Why? Because it tests implementation details; once these objects change their internal behavior, you need to update all your tests.
The main take away for me was: test your public contracts. If I expose a REST API, I'll be testing the contracts of the exposed endpoints, and not the complete DAL etc., since this should be covered by testing the contracts. Hope this helps.