Advanced Python testing with Pytest
Solving complex functional testing with Python
Topic: Software Development
The popular testing tool pytest is great for unit testing, but it can do so much more. However, learning how to use pytest for functional and integration testing requires a detailed approach lacking in most introductory training resources.
Join experts Alfredo Deza and Noah Gift to get a better grasp on solving a complex test matrix with ease, including performing highly functional tests with databases, web services, and containers. You’ll go from basic test runs that although sufficient don’t really help in the case of failure all the way to adding advanced techniques expanding on the framework—making all of these changes live and debugging as you progress.
What you'll learn-and how you can apply it
By the end of this live online course, you’ll understand:
- Important differences between functional, integration, and unit testing
- How to implement complex setups for functional testing like temporary databases
- How to enhance error reporting with custom pytest hooks
- How to connect containerized testing with fixtures
- How to use tox and pytest to build a large test matrix
And you’ll be able to:
- Manage a testing matrix, from smallest to largest
- Create, configure, and tear down complicated functional test setups
- Use Python to test containers and other remote services
- Improve failure reporting, customized to specific business requirements
This training course is for you because...
- You’re a data scientist, student, or developer already using Python, and you want to level up your testing and pytest knowledge.
- You’re involved in testing and are looking for the best ways to tackle complex testing scenarios like containers and web services.
- A working knowledge of Python
- A computer with the latest version of pytest installed and the course repository cloned
- Read “Debugging with Pytest,” “Pytest Fixtures and Plugins,” and “Continuous Integration and Continuous Delivery” (chapters 6,7, and 10 in Testing in Python)
- Read “Continuous Integration and Continuous Deployment” and “Pytest for DevOps” (chapters 6 and 8 in Python for DevOps)
- Explore pytest examples (online docs)
About your instructors
Noah Gift is lecturer and consultant in both the UC Davis Graduate School of Management’s MSBA program and Northwestern’s graduate data science program, MSDS, where he teaches and designs graduate machine learning, AI, and data science courses and consults on machine learning and cloud architecture for students and faculty. These responsibilities include leading a multicloud certification initiative for students. He’s the author of close to 100 technical publications, including two books on subjects ranging from cloud machine learning to DevOps. Noah has approximately 20 years’ experience programming in Python. He’s a Python Software Foundation Fellow, an AWS Subject Matter Expert (SME) on machine learning, an AWS Certified Solutions Architect and AWS Academy Accredited Instructor, a Google Certified Professional Cloud Architect, and a Microsoft MTA on Python. Over his career, he’s served in roles ranging from CTO, general manager, and consulting CTO to cloud architect at companies including ABC, Caltech, Sony Imageworks, Disney Feature Animation, Weta Digital, AT&T, Turner Studios, and Linden Lab. In the last 10 years, he’s been responsible for shipping many new products that generated millions of dollars of revenue and had global scale. Currently, he’s consulting startups and other companies. Noah holds an MBA from UC Davis, an MS in computer information systems from Cal State Los Angeles, and a BS in nutritional science from Cal Poly San Luis Obispo.
Alfredo Deza is a passionate software engineer, speaker, author, and former Olympic athlete with almost two decades of DevOps and software engineering experience. He currently teaches several courses about Python and Machine Learning Engineering, and gives worldwide lectures about software development, personal development, and professional sports. Alfredo has written several books about DevOps and Python, and continues to share his knowledge about resilient infrastructure, testing, and robust development practices in courses, books, and presentations.
The timeframes are only estimates and may vary according to how the class is progressing
Integration testing (55 minutes)
- Presentation: The differences between unit, integration, and functional testing; simplifying complicated test setups with fixtures
- Hands-on exercise: Create an advanced pytest fixture
Break (5 minutes)
Functional testing (55 minutes)
- Presentation: How to solve complex functional testing scenarios; testing containers; remote system testing validation with test-infra
- Hands-on exercise: Build a test matrix and add test strategies to it
Break (5 minutes)
pytest hooks (55 minutes)
- Presentation: Enrich test session information with extra header information; enhance failure reporting with container logs
- Hands-on exercise: Create an assert comparison hook
Break (5 minutes)
CI/CD integration (50 minutes)
- Presentation: GitHub Actions enhancements; integrating with Google Cloud Build; automating further with CircleCI and GitLab
- Hands-on exercise: Create your own integration with Azure Pipelines
Wrap-up and Q&A (10 minutes)