Python Pytest for Non-Programmers
Contact us to book this course
Curriculum
Python
Delivery methods
On-Site, Virtual
Duration
1 day
You do not have to be an expert or even a journeyman in Python to learn how to use pytest to create test frameworks for programs, functions, packages, modules, and APIs. After learning the Python concept and functions needed for writing pytest, you will learn how to use assert to test Python. This is followed by an introduction to parameters and fixtures to reduce typing and create reusable passages of code. Mocking is introduced to show how to test an external interface. A simple method of using classes and directories is explored for the management of tests.
Learning objectives
- How to write a test case
- How to execute a test case
- How to use fixtures for setup and teardown
- How to group test functions
- How to test a user interface with mocking
Who should attend
Individuals with only a minimal knowledge of Python who need to use a testing framework to test programs, functions, packages, modules, and APIs.
Prerequisites
Fundamental knowledge of command line.
Course outline
- Simple Editor for Creating Files
- Simple print
- if and for Statement
- Simple Functions (def and return)
- Context Manager (with)
- assert Statement
- Simple Class Creation
- Introduction to Import
- How to Find Documentation
- Exercise
- Using assert
- Testing for Expected Exceptions
- How to Write a Test Function
- Grouping Tests in Classes
- Using a Subset of Tests
- Documenting Tests
- Exercise
- Tests Anatomy
- Introduction to Fixtures
- Using Fixtures for setup and teardown
- Exercise
- What Is Parametrization?
- Parameterizing Functions
- Parameterizing Classes
- Exercise
- What Is Mocking?
- Monkey Patching
- Mocking Classes and Methods
- Creating Errors
- Exercise
- Test Planning
- Features to Test
- Creating Test Cases