Tag

HTTP Mocking

1 views collected around this technical thread.

Test Development Learning Exchange
Test Development Learning Exchange
May 26, 2024 · Backend Development

Using requests-mock to Simulate HTTP Requests in Python Unit Tests

This guide introduces the Python requests‑mock library, explains how to install it, and provides ten detailed code examples demonstrating how to mock GET, POST, status codes, regex URLs, multiple responses, JSON payloads, HEAD requests, exceptions, query parameters, and redirects for reliable unit testing.

BackendHTTP MockingUnit Testing
0 likes · 6 min read
Using requests-mock to Simulate HTTP Requests in Python Unit Tests
Test Development Learning Exchange
Test Development Learning Exchange
Apr 20, 2024 · Backend Development

Introduction to HTTPretty: Mocking HTTP Requests in Python

HTTPretty is a Python library for testing that enables lightweight, precise mocking of HTTP/HTTPS requests and responses, offering isolation, speed, complex scenario simulation, and data protection, illustrated with five practical code examples covering token retrieval, webhook handling, error simulation, timeout testing, and pagination.

APIHTTP MockingHTTPretty
0 likes · 8 min read
Introduction to HTTPretty: Mocking HTTP Requests in Python