Mocking
Mocking replaces real components or external services with controlled substitutes, letting tests exercise code without relying on live networks, databases, clocks, or other unpredictable dependencies. It helps isolate behavior, reproduce edge cases, reduce test time, and avoid side effects such as sending real requests or modifying production data. Mocks can stand in for individual functions, HTTP endpoints, sockets, or asynchronous operations, depending on what a test needs to control.
Open source mocking tools include libraries for replacing functions and objects, intercepting HTTP or socket traffic, recording and replaying requests, and generating test data. When choosing one, consider the languages and interfaces it supports, compatibility with your test framework, setup requirements, license, documentation, and maintenance activity. Mocking is useful to developers and test engineers building reliable unit, integration, and application tests.
6 repositories · updated August 4, 2026

Freezegun: Time Travel for Your Python Tests
Freezegun is a powerful Python library designed to simplify testing by allowing your tests to travel through time. It achieves this by mocking the `datetime` module, enabling developers to freeze time at a specific point or even simulate its progression. This functionality is crucial for ensuring consistent and reliable test results when dealing with time-sensitive logic.

Mocket: A Comprehensive Socket Mocking Framework for Python
Mocket is a powerful Python framework designed for monkey-patching the `socket` and `ssl` modules, enabling robust testing of network-dependent applications. It serves as both a low-level framework for building custom clients and a ready-to-use mock for HTTP/HTTPS calls, supporting various environments including asyncio and MicroPython. This tool simplifies the process of isolating and testing Python clients that communicate over the socket protocol.

vcrpy: Simplify and Speed Up Python HTTP Testing
vcrpy is a Python library that automatically mocks your HTTP interactions, making testing simpler and significantly faster. Inspired by Ruby's VCR, it records HTTP requests and responses to a 'cassette' file during the first test run, then replays them in subsequent runs, eliminating actual network traffic. This approach ensures deterministic tests, allows offline development, and boosts test execution speed.

Mimesis: A Powerful Python Library for Realistic Fake Data Generation
Mimesis is a robust Python library designed for generating fake yet realistic data across various languages and locales. It simplifies the creation of diverse data types, from personal information to financial details. This makes it an invaluable tool for development, testing, and anonymization tasks.

responses: Mocking Python Requests for Robust Testing
responses is a Python library designed to simplify the process of mocking the `requests` library during testing. It allows developers to define predictable HTTP responses, enabling isolated and reliable unit tests for applications that interact with external APIs. This utility is essential for ensuring test stability and speed by avoiding actual network calls.

Keploy: API, Integration, and E2E Testing Agent for Developers
Keploy is an innovative developer-centric tool designed to simplify API and integration testing. It automatically generates tests and data mocks directly from user traffic, leveraging eBPF for code-less and language-agnostic operation. This powerful agent helps developers achieve high test coverage and streamline their testing workflows efficiently.