Two Scoops of Django Study Session 15
Key point
We reviewed Django testing principles and documentation together, along with the possibility of adopting pytest.
Details
We read Chapters 22 and 23 of Two Scoops of Django together and reviewed the fundamentals of testing and documentation. We reaffirmed that while everyone agrees on the usefulness of tests, actually getting started is hard, and that documentation needs a solid structure to be maintained for a long time.
To write proper tests, the following principles were important.
- Keeping one test method = one test makes it possible to quickly find the cause of a failure.
- If test code becomes too complex, it's actually a sign to go back and review the real code.
- Don't apply DRY too strictly in tests; prioritize understandability instead.
- Rather than blindly trusting old fixtures, tools like
factory_boy,model_mommy, andmockcan be considered. - You can add an element of fun to testing by checking coverage with
codecovor hunting down untested code.
In the documentation part, we learned the flow of structuring documents based on reStructuredText, building them with sphinx, and deploying them to places like readthedocs.io. The key point was managing documentation not just by writing it, but as a system that includes building and deployment.
In the advanced section, we covered pytest. Compared to unittest or django.test, it has less boilerplate and more detailed output, and it can be applied to Django projects via pytest-django. Considering that existing tests can be migrated gradually, it was concluded that this is an option worth trying to introduce at 8 Percent going forward.
Finally, we shared the experience that testing reduces development anxiety and makes it possible to more stably develop new features alongside improving existing ones. We wrapped up with the message to start testing even from small functions.
This summary was generated automatically by AI. Check the original for the author's claims and context. Copyright belongs to the original author.
Our guide explains how the AI works. Report summary errors, attribution issues, or removal requests via Contact.