Unit Testing in Django
52mIntermediate2022-07-13
Authors
Leticia Portella
Software Developer | Podcaster | Oceanographer
Course details
Tests are at the heart of modern software development, and testing is a skill that should be as basic as building the applications. In this course, Leticia Portella uses an untested Django application to teach you about the tools and good practices of writing tests. Learn about Pytest, one of the most known and complete testing frameworks in Python. Explore how you can use Pytest to test a Django application, from building your first unit tests to learning how to think about what makes a good test. Review several tests you can run with Pytest and Django, including testing a GET endpoint and testing behavior when a user is authenticated. Walk through the layers of security that Pytest adds to protect you from accidents. Find out how being lazy while writing tests can be leveraged to write better tests faster. Finally, discover how to quickly create instances and use tools to avoid rewriting code. This is the ideal course to follow Leticia’s first course, Django Essential Training.
Skills covered
DjangoSoftware TestingBack-End Web DevelopmentFull-Stack Web DevelopmentWeb DevelopmentOpen SourceSoftware DevelopmentOne-Off
Concepts
0. Introduction
- 01 - Unit test with Django
- 02 - Why tests matter
1. Welcome to pytest
- 03 - What is pytest
- 04 - Setting up pytest on Django
- 05 - Building your first unit test
- 06 - Getting familiar with pytest output
- 07 - Where should tests live
2. pytest and Django
- 08 - Testing a GET endpoint
- 09 - How to test the behavior when a user is authenticated
- 10 - A bit more on the beauty of pytest
- 11 - Being mindful of your test suite
- 12 - Testing the list endpoint
- 13 - Have you tested enough
3. Being Lazy Is an Advantage
- 14 - Being lazy - pytest fixtures
- 15 - One step beyond the laziness
- 16 - Lazy notes make your tests even smarter
4. Going Beyond
- 17 - Testing the Create endpoint
- 18 - Test is culture
Conclusion
- 19 - Learn more