HTTP client mocking tool for Python - inspired by Fakeweb for Ruby

Overview

HTTPretty 1.0.5

https://github.com/gabrielfalcao/HTTPretty/raw/master/docs/source/_static/logo.svg?sanitize=true

HTTP Client mocking tool for Python created by Gabriel Falcão . It provides a full fake TCP socket module. Inspired by FakeWeb

Python Support:

  • 3.6
  • 3.7
  • 3.8
  • 3.9
https://img.shields.io/pypi/dm/HTTPretty https://img.shields.io/codecov/c/github/gabrielfalcao/HTTPretty https://img.shields.io/github/workflow/status/gabrielfalcao/HTTPretty/HTTPretty%20Tests?label=Python%203.6%20-%203.9 https://img.shields.io/readthedocs/httpretty https://img.shields.io/github/license/gabrielfalcao/HTTPretty?label=Github%20License https://img.shields.io/pypi/v/HTTPretty https://img.shields.io/pypi/l/HTTPretty?label=PyPi%20License https://img.shields.io/pypi/format/HTTPretty https://img.shields.io/pypi/status/HTTPretty https://img.shields.io/pypi/pyversions/HTTPretty https://img.shields.io/pypi/implementation/HTTPretty https://img.shields.io/snyk/vulnerabilities/github/gabrielfalcao/HTTPretty https://img.shields.io/github/v/tag/gabrielfalcao/HTTPretty

Install

pip install httpretty

Common Use Cases

  • Test-driven development of API integrations
  • Fake responses of external APIs
  • Record and playback HTTP requests

Simple Example

import sure
import httpretty
import requests


@httpretty.activate
def test_httpbin():
    httpretty.register_uri(
        httpretty.GET,
        "https://httpbin.org/ip",
        body='{"origin": "127.0.0.1"}'
    )

    response = requests.get('https://httpbin.org/ip')
    response.json().should.equal({'origin': '127.0.0.1'})

    httpretty.latest_requests().should.have.length_of(1)
    httpretty.last_request().should.equal(httpretty.latest_requests()[0])
    httpretty.last_request().body.should.equal('{"origin": "127.0.0.1"}')

checking multiple responses

@httpretty.activate
def test_post_bodies():
    url = 'http://httpbin.org/post'
    httpretty.register_uri(httpretty.POST, url, status=200)
    httpretty.register_uri(httpretty.POST, url, status=400)
    requests.post(url, data={'foo': 'bar'})
    requests.post(url, data={'zoo': 'zoo'})
    assert 'foo=bar' in httpretty.latest_requests()[0].body
    assert 'zoo=bar' in httpretty.latest_requests()[1].body

License

<HTTPretty - HTTP client mock for Python>
Copyright (C) <2011-2021> Gabriel Falcão <[email protected]>

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

Main contributors

HTTPretty has received many contributions but some folks made remarkable contributions and deserve extra credit:

Owner
Gabriel Falcão
Software Engineer, New York Times
Gabriel Falcão
One-stop solution for HTTP(S) testing.

HttpRunner HttpRunner is a simple & elegant, yet powerful HTTP(S) testing framework. Enjoy! ✨ 🚀 ✨ Design Philosophy Convention over configuration ROI

HttpRunner 3.5k Jan 04, 2023
Set your Dynaconf environment to testing when running pytest

pytest-dynaconf Set your Dynaconf environment to testing when running pytest. Installation You can install "pytest-dynaconf" via pip from PyPI: $ pip

David Baumgold 3 Mar 11, 2022
reCaptchaBypasser For Bypass Any reCaptcha For Selenium Python

reCaptchaBypasser ' Usage : from selenium import webdriver from reCaptchaBypasser import reCaptchaScraper import time driver = webdriver.chrome(execu

Dr.Linux 8 Dec 17, 2022
Find index entries in $INDEX_ALLOCATION attributes

INDXRipper Find index entries in $INDEX_ALLOCATION attributes Timeline created using mactime.pl on the combined output of INDXRipper and fls. See: sle

32 Nov 05, 2022
Sixpack is a language-agnostic a/b-testing framework

Sixpack Sixpack is a framework to enable A/B testing across multiple programming languages. It does this by exposing a simple API for client libraries

1.7k Dec 24, 2022
Android automation project with pytest+appium

Android automation project with pytest+appium

1 Oct 28, 2021
Lightweight, scriptable browser as a service with an HTTP API

Splash - A javascript rendering service Splash is a javascript rendering service with an HTTP API. It's a lightweight browser with an HTTP API, implem

Scrapinghub 3.8k Jan 03, 2023
A testing system for catching visual regressions in Web applications.

Huxley Watches you browse, takes screenshots, tells you when they change Huxley is a test-like system for catching visual regressions in Web applicati

Facebook Archive 4.1k Nov 30, 2022
Main purpose of this project is to provide the service to automate the API testing process

PPTester project Main purpose of this project is to provide the service to automate the API testing process. In order to deploy this service use you s

4 Dec 16, 2021
Python Webscraping using Selenium

Web Scraping with Python and Selenium The code shows how to do web scraping using Python and Selenium. We use as data the https://sbot.org.br/localize

Luís Miguel Massih Pereira 1 Dec 01, 2021
Mimesis is a high-performance fake data generator for Python, which provides data for a variety of purposes in a variety of languages.

Mimesis - Fake Data Generator Description Mimesis is a high-performance fake data generator for Python, which provides data for a variety of purposes

Isaak Uchakaev 3.8k Dec 29, 2022
A simple tool to test internet stability.

pingtest Description A personal project for testing internet stability, intended for use in Linux and Windows.

chris 0 Oct 17, 2021
Python Projects - Few Python projects with Testing using Pytest

Python_Projects Few Python projects : Fast_API_Docker_PyTest- Just a simple auto

Tal Mogendorff 1 Jan 22, 2022
Codeforces Test Parser for C/C++ & Python on Windows

Codeforces Test Parser for C/C++ & Python on Windows Installation Run pip instal

Minh Vu 2 Jan 05, 2022
Code coverage measurement for Python

Coverage.py Code coverage testing for Python. Coverage.py measures code coverage, typically during test execution. It uses the code analysis tools and

Ned Batchelder 2.3k Jan 04, 2023
An interactive TLS-capable intercepting HTTP proxy for penetration testers and software developers.

mitmproxy mitmproxy is an interactive, SSL/TLS-capable intercepting proxy with a console interface for HTTP/1, HTTP/2, and WebSockets. mitmdump is the

mitmproxy 29.7k Jan 02, 2023
A test fixtures replacement for Python

factory_boy factory_boy is a fixtures replacement based on thoughtbot's factory_bot. As a fixtures replacement tool, it aims to replace static, hard t

FactoryBoy project 3k Jan 05, 2023
🐍 Material for PyData Global 2021 Presentation: Effective Testing for Machine Learning Projects

Effective Testing for Machine Learning Projects Code for PyData Global 2021 Presentation by @edublancas. Slides available here. The project is develop

Eduardo Blancas 73 Nov 06, 2022
Green is a clean, colorful, fast python test runner.

Green -- A clean, colorful, fast python test runner. Features Clean - Low redundancy in output. Result statistics for each test is vertically aligned.

Nathan Stocks 756 Dec 22, 2022
Ward is a modern test framework for Python with a focus on productivity and readability.

Ward is a modern test framework for Python with a focus on productivity and readability.

Darren Burns 1k Dec 31, 2022