[Pytest 101] 04 Mock Class
An introduction to two approaches for testing class instantiation when using the Factory Pattern, with practical examples using pytest-mock.
A Bit everyday A Byte every week
An introduction to two approaches for testing class instantiation when using the Factory Pattern, with practical examples using pytest-mock.
Free your unit tests from database dependencies using mocks.
How to use Mock to simulate behavior, raise exceptions, and test side effects.
After covering the basic tools, this article demonstrates how to use mocks effectively in Pytest.
Mocks allow us to replace the logic of real functions to simulate different scenarios and write more precise unit tests.
We’ll walk through examples of mocking functions, simulating errors, and even handling external dependencies like Redis.
An introduction to Pytest and the core concepts of Mock
Setting up a Python development environment on Mac
Create a Discord chat bot for rolling dice using Python
Creating a basic Discord chat bot using Python