HTTP client mock for Python
Project Links
Meta
Author: Gabriel Falcao
Requires Python: >=3
Classifiers
Development Status
- 5 - Production/Stable
Intended Audience
- Developers
License
- OSI Approved :: MIT License
Programming Language
- Python :: 3
- Python :: 3.6
- Python :: 3.7
- Python :: 3.8
- Python :: 3.9
- Python
Topic
- Internet :: WWW/HTTP
- Software Development :: Testing
HTTPretty 1.1.4
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
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(verbose=True, allow_net_connect=False)
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(verbose=True, allow_net_connect=False) 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 <gabriel@nacaolivre.org> 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:
Andrew Gross ~> @andrewgross
Hugh Saunders ~> @hughsaunders
James Rowe ~> @JNRowe
Matt Luongo ~> @mhluongo
Steve Pulec ~> @spulec
Miro Hrončok ~> @hroncok Mario Jonke ~> @mariojonke
Aug 16, 2021
1.1.4
May 24, 2021
1.1.3
May 20, 2021
1.1.2
May 14, 2021
1.1.1
May 13, 2021
1.1.0
Jan 06, 2021
1.0.5
Jan 05, 2021
1.0.4
Nov 24, 2020
1.0.3
Mar 26, 2020
1.0.2
Mar 26, 2020
1.0.1
Mar 26, 2020
1.0.0
Oct 09, 2019
0.9.7
Nov 04, 2018
0.9.6
Jun 06, 2018
0.9.5
Apr 28, 2018
0.9.4
Apr 28, 2018
0.9.3
Apr 28, 2018
0.9.2
Apr 28, 2018
0.9.1
Jan 18, 2016
0.8.14
Dec 14, 2015
0.8.12
Dec 14, 2015
0.8.11
May 18, 2015
0.8.10
May 11, 2015
0.8.9
Mar 11, 2015
0.8.8
Feb 21, 2015
0.8.7
Feb 21, 2015
0.8.6
Feb 20, 2015
0.8.5
Feb 03, 2015
0.8.4
Jun 19, 2014
0.8.3
Jun 19, 2014
0.8.2
Jun 19, 2014
0.8.1
Feb 03, 2014
0.8.0
Dec 12, 2013
0.7.1
Oct 07, 2013
0.7.0
Sep 30, 2013
0.6.5
Sep 23, 2013
0.6.4
Jul 08, 2013
0.6.3
Jun 20, 2013
0.6.2
Jun 04, 2013
0.6.1
Apr 18, 2013
0.6.0
Apr 15, 2013
0.5.14
Mar 25, 2013
0.5.13
Mar 16, 2013
0.5.12
Mar 12, 2013
0.5.11
Feb 19, 2013
0.5.10
Feb 18, 2013
0.5.9
Feb 14, 2013
0.5.8
Feb 14, 2013
0.5.7
Jan 29, 2013
0.5.6
Dec 10, 2012
0.5.5
Nov 24, 2012
0.5.4
Nov 19, 2012
0.5.3
Nov 12, 2012
0.5.2
Nov 08, 2012
0.5.1
Nov 08, 2012
0.5
Jun 30, 2011
0.4
Jun 28, 2011
0.3
Jun 26, 2011
0.2
May 05, 2011
0.1
Files in release
No dependencies