Create, configure, and extend tests with Pytest
Testing, and unit-testing in particular, is one of the principal pillars for writing robust software. Although Python comes with a unit testing library, it is not easily extensible, it is hard to understand, and it doesn’t include an easy way to run and report on tests.
Learn the different types of testing like functional and load testing. Tools like Pytest, Coverage, Molotov, and Tox will be covered in enough detail to apply them to existing projects and get them to a solid production state.
And finally, learn how to integrate the different types of testing and tooling into continuous integration / continuous delivery platforms like Jenkins to ensure a smooth deployment (or release).
What you'll learn-and how you can apply it
- Understand best practices to write and extend test suites using Pytest.
- Extend Pytest with ad-hoc plugins, fixtures, and parametrization.
- Enhance coverage, reporting, and improve robustness with readable tests.
- Perform load testing.
- Support different Python versions and other ad-hoc testing with Tox.
- Produce solid deployments by configuring git services like Github or Gitlab to execute tests automatically when merging and before merging code.
This training course is for you because...
- You work as a software engineer, and you are exposed to production code that could use new tests to be written or improve existing unit tests to get better validation.
- You work as a data scientist and want to better understand how to validate and enhance robustness to production code.
- You are a student with some exposure to Python and want to gain knowledge on the industry’s best standards for producing code that is well tested.
- Beginner to intermediate level Python experience
- Free Github account: https://github.com
- Python 3 https://www.python.org/downloads
- Watch Essential Machine Learning and AI with Python and Jupyter Notebook (video)
- Watch Data Engineering with Python and AWS Lambda LiveLessons (video)
- Watch Python Programming Language (video)
About your instructor
Alfredo Deza is a former professional athlete and Olympian, with 10 years of professional Python and DevOps experience, creating large CI/CD environments for testing and deployments, has designed resilient infrastructure for several companies, and has instilled his passion for testing to others by automating code checks and production deployments. He has co-authored O'reilly's Python For DevOps and Testing In Python books, as well as training courses for Pearson and Udacity.
The timeframes are only estimates and may vary according to how the class is progressing
Part 1: Introduction to Pytest Length (45 min)
- Get started with pytest
- Install and get started with pytest
- Simple pytest usage
- Basic pytest invocation
- Create pytest reports
- Monkeypatching with pytest
- Temporary directories
- Exploring built-in fixtures with pytest
- Install and use pytest plugins
- QA (10 min)
- Break (5 min)
Part 2: Advanced Pytest usage Length 45 min
- Debug pytest
- Integrate PDB (Python Debugger) with pytest
- Stop pytest on failure
- Filter specific tests on the command line
- Using pytest fixtures
- Setup a test with fixtures in pytest
- Share test data with pytest
- Parametrize fixtures with pytest
- Group test by fixtures with pytest
- QA (10 min)
- Break (5 min)