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:

Comments
  • HTTPretty breaking other URLs

    HTTPretty breaking other URLs

    With the following test

    @httprettified
    def test_httpretty_should_not_override_other_urls():
        u"HTTPretty shouldn't break other URLs"
    
        HTTPretty.register_uri(HTTPretty.GET, "http://github.com/foo",
                               body="<root><baz /</root>")
    
        response = requests.get('http://google.com/')
        expect(response.status_code).to.equal(200)
    

    I get

      File "HTTPretty/tests/functional/test_requests.py", line 153, in test_httpretty_should_not_override_other_urls
        response = requests.get('http://google.com/')
      File "HTTPretty/lib/python2.7/site-packages/requests/api.py", line 55, in get
        return request('get', url, **kwargs)
      File "HTTPretty/lib/python2.7/site-packages/requests/api.py", line 44, in request
        return session.request(method=method, url=url, **kwargs)
      File "HTTPretty/lib/python2.7/site-packages/requests/sessions.py", line 289, in request
        history = [r for r in gen] if allow_redirects else []
      File "HTTPretty/lib/python2.7/site-packages/requests/sessions.py", line 133, in resolve_redirects
        proxies=proxies
      File "HTTPretty/lib/python2.7/site-packages/requests/sessions.py", line 279, in request
        resp = self.send(prep, stream=stream, timeout=timeout, verify=verify, cert=cert, proxies=proxies)
      File "HTTPretty/lib/python2.7/site-packages/requests/sessions.py", line 374, in send
        r = adapter.send(request, **kwargs)
      File "HTTPretty/lib/python2.7/site-packages/requests/adapters.py", line 222, in send
        r.content
      File "HTTPretty/lib/python2.7/site-packages/requests/models.py", line 550, in content
        self._content = bytes().join(self.iter_content(CONTENT_CHUNK_SIZE)) or bytes()
      File "HTTPretty/lib/python2.7/site-packages/requests/models.py", line 496, in generate
        chunk = self.raw.read(chunk_size)
      File "HTTPretty/lib/python2.7/site-packages/requests/packages/urllib3/response.py", line 148, in read
        return self._fp.read(amt)
      File "python2.7/httplib.py", line 541, in read
        return self._read_chunked(amt)
      File "python2.7/httplib.py", line 592, in _read_chunked
        value.append(self._safe_read(amt))
      File "python2.7/httplib.py", line 649, in _safe_read
        raise IncompleteRead(''.join(s), amt)
    IncompleteRead: IncompleteRead(532 bytes read)
    
    opened by spulec 28
  • Python 3.7 test failures (SSL related)

    Python 3.7 test failures (SSL related)

    https://travis-ci.org/hroncok/HTTPretty/jobs/381122886

       AssertionError: Traceback (most recent call last):
         File "/opt/python/3.7-dev/lib/python3.7/urllib/request.py", line 1316, in do_open
           encode_chunked=req.has_header('Transfer-encoding'))
         File "/opt/python/3.7-dev/lib/python3.7/http/client.py", line 1229, in request
           self._send_request(method, url, body, headers, encode_chunked)
         File "/opt/python/3.7-dev/lib/python3.7/http/client.py", line 1275, in _send_request
           self.endheaders(body, encode_chunked=encode_chunked)
         File "/opt/python/3.7-dev/lib/python3.7/http/client.py", line 1224, in endheaders
           self._send_output(message_body, encode_chunked=encode_chunked)
         File "/opt/python/3.7-dev/lib/python3.7/http/client.py", line 1016, in _send_output
           self.send(msg)
         File "/opt/python/3.7-dev/lib/python3.7/http/client.py", line 977, in send
           self.sock.sendall(data)
         File "/opt/python/3.7-dev/lib/python3.7/ssl.py", line 987, in sendall
           return socket.sendall(self, data, flags)
       BrokenPipeError: [Errno 32] Broken pipe
       
       During handling of the above exception, another exception occurred:
       
       Traceback (most recent call last):
         File "/home/travis/virtualenv/python3.7-dev/lib/python3.7/site-packages/sure/__init__.py", line 186, in wrap
           func(start, *args, **kw)
         File "/home/travis/build/hroncok/HTTPretty/tests/functional/test_urllib2.py", line 191, in test_httpretty_should_support_a_list_of_successive_responses_urllib2
           request1 = urlopen('https://api.yahoo.com/test')
         File "/opt/python/3.7-dev/lib/python3.7/urllib/request.py", line 222, in urlopen
           return opener.open(url, data, timeout)
         File "/opt/python/3.7-dev/lib/python3.7/urllib/request.py", line 525, in open
           response = self._open(req, data)
         File "/opt/python/3.7-dev/lib/python3.7/urllib/request.py", line 543, in _open
           '_open', req)
         File "/opt/python/3.7-dev/lib/python3.7/urllib/request.py", line 503, in _call_chain
           result = func(*args)
         File "/opt/python/3.7-dev/lib/python3.7/urllib/request.py", line 1359, in https_open
           context=self._context, check_hostname=self._check_hostname)
         File "/opt/python/3.7-dev/lib/python3.7/urllib/request.py", line 1318, in do_open
           raise URLError(err)
    

    https://travis-ci.org/hroncok/HTTPretty/jobs/381122887

       Traceback (most recent call last):
        /home/travis/virtualenv/python3.7-dev/lib/python3.7/site-packages/nose/case.py line 198 in runTest
          self.test(*self.arg)
        httpretty/core.py line 1631 in wrapper
          return test(*args, **kw)
        tests/pyopenssl/test_mock.py line 42 in test_httpretty_overrides_when_pyopenssl_installed
          response = requests.get('https://yipit.com')
        /home/travis/virtualenv/python3.7-dev/lib/python3.7/site-packages/requests/api.py line 72 in get
          return request('get', url, params=params, **kwargs)
        /home/travis/virtualenv/python3.7-dev/lib/python3.7/site-packages/requests/api.py line 58 in request
          return session.request(method=method, url=url, **kwargs)
        /home/travis/virtualenv/python3.7-dev/lib/python3.7/site-packages/requests/sessions.py line 508 in request
          resp = self.send(prep, **send_kwargs)
        /home/travis/virtualenv/python3.7-dev/lib/python3.7/site-packages/requests/sessions.py line 618 in send
          r = adapter.send(request, **kwargs)
        /home/travis/virtualenv/python3.7-dev/lib/python3.7/site-packages/requests/adapters.py line 506 in send
          raise SSLError(e, request=request)
       SSLError: HTTPSConnectionPool(host='yipit.com', port=443): Max retries exceeded with url: / (Caused by SSLError(CertificateError("wildcard can only be present in the leftmost segment: '*yipit.com'")))
    

    Also with Python 3.7.0b4 on Fedora:

    AssertionError: Traceback (most recent call last):
         File "/home/churchyard/Dokumenty/RedHat/HTTPretty/.tox/py37/lib/python3.7/site-packages/sure/__init__.py", line 186, in wrap
           func(start, *args, **kw)
         File "/home/churchyard/Dokumenty/RedHat/HTTPretty/tests/functional/test_httplib2.py", line 278, in test_callback_response
           'https://api.yahoo.com/test', 'GET')
         File "/home/churchyard/Dokumenty/RedHat/HTTPretty/.tox/py37/lib/python3.7/site-packages/httplib2/__init__.py", line 1514, in request
           (response, content) = self._request(conn, authority, uri, request_uri, method, body, headers, redirections, cachekey)
         File "/home/churchyard/Dokumenty/RedHat/HTTPretty/.tox/py37/lib/python3.7/site-packages/httplib2/__init__.py", line 1264, in _request
           (response, content) = self._conn_request(conn, request_uri, method, body, headers)
         File "/home/churchyard/Dokumenty/RedHat/HTTPretty/.tox/py37/lib/python3.7/site-packages/httplib2/__init__.py", line 1187, in _conn_request
           conn.connect()
         File "/home/churchyard/Dokumenty/RedHat/HTTPretty/.tox/py37/lib/python3.7/site-packages/httplib2/__init__.py", line 1013, in connect
           self.sock = self._context.wrap_socket(sock, server_hostname=self.host)
         File "/usr/lib64/python3.7/ssl.py", line 412, in wrap_socket
           session=session
         File "/usr/lib64/python3.7/ssl.py", line 817, in _create
           super(SSLSocket, self).__init__(**kwargs)
       TypeError: super(type, obj): obj must be an instance or subtype of type
    

    But fallbacks to broken pipe above if I do crazy changes in SSLSocket from the stdlib.

    cc @tiran because I have no idea what's going on here.

    opened by hroncok 20
  • is HTTPretty

    is HTTPretty "upstream" dead?

    started to use HTTPretty for one of the projects but immediately ran into side-effects of it while testing on travis with python 3.4.2... from activity in the bug tracker and pull requests got impression that unfortunately @gabrielfalcao seems to have no more of interest/free time to push it forward. So for myself I see two possible ways

    1. immediately stop using it
    2. help to maintain it

    in case of 2 I see

    2.1. @gabrielfalcao brings more developers on board (I could help from time to time) so outstanding PRs and issues are slowly getting dealt with 2.2. we fork it into e.g. HTTPrettiest ;) 2.3. (meld of 2.2 and 2.1) @gabrielfalcao blesses us to fork it while keeping its name

    I would prefer 2.1. For any of 2. it would work if there is more people with interest and expertise to join.

    opened by yarikoptic 18
  • feat: leaner requirements, improved tox/travis support

    feat: leaner requirements, improved tox/travis support

    This patch builds off of #128 and #129. The log speaks:

        This patch reorganizes the requirements to install only what's
        necessary for using httpretty. This greatly reduces installation time
        when being pulled in as a dependency for another project. The only
        library required to use httpretty is urllib3.
    
        The remaining requirements were either pruned or relocated to
        test-requirements.txt. Those that were pruned were either not needed
        or used for non-testing/non-core purposes. Those that were relocated
        were actively used in either unit or functional tests.
    
        The tox file and the travis yaml have been updated to reflect the
        changes in the requirements files.
    
        Finally, travis.yaml has leveled up. It now supports running the test
        suite using pypy and python 3.3, with the added benefit that a build
        will still be marked as successful even if py3.3 and pypy fail.
    
    opened by queertypes 18
  • Python 3.3 support

    Python 3.3 support

    This pull request is just a reference to the branch I created. As a result of an ongoing discussion brought up by @jamielennox at #118

    In short python 3.3 support is going to be beneficial to some linux distributions.

    The goal is to run tox and have all the tests passing for python 2.6, 2.7 and 3.3

    opened by gabrielfalcao 17
  • Attempting to create a wheel with the latest httpretty fails

    Attempting to create a wheel with the latest httpretty fails

    I get the following error:

    $ pip wheel httpretty
    Downloading/unpacking httpretty
      Using download cache from /Users/alex_gaynor/.pip/cache/https%3A%2F%2Fpypi.python.org%2Fpackages%2Fsource%2Fh%2Fhttpretty%2Fhttpretty-0.8.0.tar.gz
      Running setup.py (path:/Users/alex_gaynor/.virtualenvs/openstack-requirements/build/httpretty/setup.py) egg_info for package httpretty
    
    Downloading/unpacking urllib3 (from httpretty)
    Building wheels for collected packages: httpretty, urllib3
      Running setup.py bdist_wheel for httpretty
      Destination directory: /Users/alex_gaynor/.pip/wheels
      Complete output from command /Users/alex_gaynor/.virtualenvs/openstack-requirements/bin/python -c "import setuptools;__file__='/Users/alex_gaynor/.virtualenvs/openstack-requirements/build/httpretty/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" bdist_wheel -d /Users/alex_gaynor/.pip/wheels:
      running bdist_wheel
    
    running build
    
    running build_py
    
    creating build
    
    creating build/lib
    
    creating build/lib/httpretty
    
    copying httpretty/__init__.py -> build/lib/httpretty
    
    copying httpretty/compat.py -> build/lib/httpretty
    
    copying httpretty/core.py -> build/lib/httpretty
    
    copying httpretty/errors.py -> build/lib/httpretty
    
    copying httpretty/http.py -> build/lib/httpretty
    
    copying httpretty/utils.py -> build/lib/httpretty
    
    installing to build/bdist.macosx-10.9-intel/wheel
    
    running install
    
    running install_lib
    
    creating build/bdist.macosx-10.9-intel
    
    creating build/bdist.macosx-10.9-intel/wheel
    
    creating build/bdist.macosx-10.9-intel/wheel/httpretty
    
    copying build/lib/httpretty/__init__.py -> build/bdist.macosx-10.9-intel/wheel/httpretty
    
    copying build/lib/httpretty/compat.py -> build/bdist.macosx-10.9-intel/wheel/httpretty
    
    copying build/lib/httpretty/core.py -> build/bdist.macosx-10.9-intel/wheel/httpretty
    
    copying build/lib/httpretty/errors.py -> build/bdist.macosx-10.9-intel/wheel/httpretty
    
    copying build/lib/httpretty/http.py -> build/bdist.macosx-10.9-intel/wheel/httpretty
    
    copying build/lib/httpretty/utils.py -> build/bdist.macosx-10.9-intel/wheel/httpretty
    
    running install_egg_info
    
    running egg_info
    
    writing requirements to httpretty.egg-info/requires.txt
    
    writing httpretty.egg-info/PKG-INFO
    
    writing top-level names to httpretty.egg-info/top_level.txt
    
    writing dependency_links to httpretty.egg-info/dependency_links.txt
    
    warning: manifest_maker: standard file '-c' not found
    
    
    
    reading manifest file 'httpretty.egg-info/SOURCES.txt'
    
    reading manifest template 'MANIFEST.in'
    
    writing manifest file 'httpretty.egg-info/SOURCES.txt'
    
    Copying httpretty.egg-info to build/bdist.macosx-10.9-intel/wheel/httpretty-0.8.0-py2.7.egg-info
    
    running install_scripts
    
    Traceback (most recent call last):
    
      File "<string>", line 1, in <module>
    
      File "/Users/alex_gaynor/.virtualenvs/openstack-requirements/build/httpretty/setup.py", line 60, in <module>
    
        "Topic :: Software Development :: Testing"],
    
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/core.py", line 152, in setup
    
        dist.run_commands()
    
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 953, in run_commands
    
        self.run_command(cmd)
    
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 972, in run_command
    
        cmd_obj.run()
    
      File "/Users/alex_gaynor/.virtualenvs/openstack-requirements/lib/python2.7/site-packages/wheel/bdist_wheel.py", line 222, in run
    
        self.distinfo_dir)
    
      File "/Users/alex_gaynor/.virtualenvs/openstack-requirements/lib/python2.7/site-packages/wheel/bdist_wheel.py", line 387, in egg2dist
    
        distribution=self.distribution)
    
      File "/Users/alex_gaynor/.virtualenvs/openstack-requirements/lib/python2.7/site-packages/wheel/metadata.py", line 160, in pkginfo_to_dict
    
        new_requirements = list(convert_requirements(requirements))
    
      File "/Users/alex_gaynor/.virtualenvs/openstack-requirements/lib/python2.7/site-packages/wheel/metadata.py", line 215, in convert_requirements
    
        parsed_requirement = pkg_resources.Requirement.parse(req)
    
      File "/Users/alex_gaynor/.virtualenvs/openstack-requirements/lib/python2.7/site-packages/pkg_resources.py", line 2611, in parse
    
        raise ValueError("No requirements found", s)
    
    ValueError: ('No requirements found', '')
    
    ----------------------------------------
      Failed building wheel for httpretty
      Skipping building wheel: file:///Users/alex_gaynor/.pip/wheels/urllib3-1.7.1-py27-none-any.whl
    Failed to build httpretty
    Cleaning up...
    

    This was originally filed as https://github.com/pypa/pip/issues/1530 but I was told that this is not a pip bug. It was also suggested that this might be fixed on head, in which case it might be nice to get this into a release.

    opened by alex 15
  • Packaging Rearrange

    Packaging Rearrange

    I've been looking at packaging this in Fedora for a while and have held off because of the dependencies. I was recently speaking to someone who was in the exact same state for Gentoo and figured that it should be fixed.

    The series essentially involves:

    • cleaning up the required dependencies, i haven't verified the minimum version number is actually required. I may need to come back and downgrade some of them if possible and there aren't the available versions packaged.
    • Adding the documentation and running files to the distributed package.
    • Moving the test files into the package. We don't necessarily include the tests in the eventual rpm but we need them to verify the rpm once built. Having tests in the package is also considered the best practice.
    opened by jamielennox 14
  • Issues with socket.sendall (0.6.5/0.7.0)

    Issues with socket.sendall (0.6.5/0.7.0)

    This doesn't seem to happen in every case, but I'm hitting an infinite loop with the sendall functionality (seems to be around line 237 in 0.6.5):

    This is simply from flushing a SELECT statement in SQLA (in 0.6.5):

    recvfrom(0xA, 0x10BB6B9BC, 0x10)         = -1 Err#35
    recvfrom(0xA, 0x10BB6B9BC, 0x10)         = -1 Err#35
    recvfrom(0xA, 0x10BB6B9BC, 0x10)         = -1 Err#35
    recvfrom(0xA, 0x10BB6B9BC, 0x10)         = -1 Err#35
    recvfrom(0xA, 0x10BB6B9BC, 0x10)         = -1 Err#35
    recvfrom(0xA, 0x10BB6B9BC, 0x10)         = -1 Err#35
    recvfrom(0xA, 0x10BB6B9BC, 0x10)         = -1 Err#35
    recvfrom(0xA, 0x10BB6B9BC, 0x10)         = -1 Err#35
    recvfrom(0xA, 0x10BB6B9BC, 0x10)         = -1 Err#35
    recvfrom(0xA, 0x10BB6B9BC, 0x10)         = -1 Err#35
    recvfrom(0xA, 0x10BB6B9BC, 0x10)         = -1 Err#35
    

    On 0.7.0 I'm seeing this, which seems to be related:

    changes/ext/pubsub.py:44: in publish
    >       self._redis.publish(channel, json.dumps(data))
    ../../.virtualenvs/changes/lib/python2.7/site-packages/redis/client.py:1447: in publish
    >       return self.execute_command('PUBLISH', channel, message)
    ../../.virtualenvs/changes/lib/python2.7/site-packages/redis/client.py:393: in execute_command
    >           connection.send_command(*args)
    ../../.virtualenvs/changes/lib/python2.7/site-packages/redis/connection.py:306: in send_command
    >       self.send_packed_command(self.pack_command(*args))
    ../../.virtualenvs/changes/lib/python2.7/site-packages/redis/connection.py:290: in send_packed_command
    >           self._sock.sendall(command)
    ../../.virtualenvs/changes/lib/python2.7/site-packages/httpretty/core.py:354: in sendall
    >               return self.real_sendall(data, *args, **kw)
    ../../.virtualenvs/changes/lib/python2.7/site-packages/httpretty/core.py:331: in real_sendall
    >               received = self.truesock.recv(self._bufsize)
    E               ValueError: negative buffersize in recv
    
    opened by dcramer 13
  • TypeError: wrap_socket() missing 1 required positional argument: 'sock'

    TypeError: wrap_socket() missing 1 required positional argument: 'sock'

    I am getting this error since the release of 0.9.5. This happens on Python 2.7, 3.4, 3.5 and 3.6.

    Here's the stack-trace:

    Traceback (most recent call last):
      File "/home/travis/build/GetStream/stream-django/.eggs/httpretty-0.9.5-py3.6.egg/httpretty/core.py", line 1636, in wrapper
        return test(*args, **kw)
      File "/home/travis/build/GetStream/stream-django/stream_django/tests/test_app/tests/test_manager.py", line 48, in test_unfollow_user
        feed_manager.unfollow_user(1, 2)
      File "/home/travis/build/GetStream/stream-django/stream_django/managers.py", line 49, in unfollow_user
        feed.unfollow(target_feed.slug, target_feed.user_id)
      File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/stream/feed.py", line 166, in unfollow
        response = self.client.delete(url, signature=token, params=params)
      File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/stream/client.py", line 271, in delete
        return self._make_request(self.session.delete, *args, **kwargs)
      File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/stream/client.py", line 210, in _make_request
        params=default_params, timeout=self.timeout)
      File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/requests/sessions.py", line 591, in delete
        return self.request('DELETE', url, **kwargs)
      File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/requests/sessions.py", line 512, in request
        resp = self.send(prep, **send_kwargs)
      File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/requests/sessions.py", line 622, in send
        r = adapter.send(request, **kwargs)
      File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/requests/adapters.py", line 445, in send
        timeout=timeout
      File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/urllib3/connectionpool.py", line 600, in urlopen
        chunked=chunked)
      File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/urllib3/connectionpool.py", line 343, in _make_request
        self._validate_conn(conn)
      File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/urllib3/connectionpool.py", line 849, in _validate_conn
        conn.connect()
      File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/urllib3/connection.py", line 356, in connect
        ssl_context=context)
      File "/home/travis/build/GetStream/stream-django/.eggs/httpretty-0.9.5-py3.6.egg/httpretty/core.py", line 600, in fake_wrap_socket
        return orig_wrap_socket_fn(*args, **kw)
      File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/urllib3/util/ssl_.py", line 359, in ssl_wrap_socket
        return context.wrap_socket(sock, server_hostname=server_hostname)
      File "/home/travis/build/GetStream/stream-django/.eggs/httpretty-0.9.5-py3.6.egg/httpretty/core.py", line 600, in fake_wrap_socket
        return orig_wrap_socket_fn(*args, **kw)
    TypeError: wrap_socket() missing 1 required positional argument: 'sock'
    

    This is happening on a public Github project during Travis (https://travis-ci.org/GetStream/stream-django/builds).

    opened by tbarbugli 12
  • Fixes a Py3.4 issue where faking SocketType breaks

    Fixes a Py3.4 issue where faking SocketType breaks

    The overall problem is that in Python 3.4 SocketType is not the same object as socket. This assumption from enable/disable caused an infinite loop when shutting down after our tests ran. If we save off the original value and restore it we no longer have an issue.

    opened by dstanek 12
  • Unable to install httpretty-0.8.11 with pip

    Unable to install httpretty-0.8.11 with pip

    Using pip 7.1.2 with Python 2.7:

    $ pip install httpretty
    Collecting httpretty
      Downloading httpretty-0.8.11.tar.gz (43kB)
        100% |████████████████████████████████| 45kB 340kB/s
        Complete output from command python setup.py egg_info:
        Traceback (most recent call last):
          File "<string>", line 20, in <module>
          File "/private/var/folders/49/9_0w6jk90gs5cs1mfg27xn0w0000gn/T/pip-build-ByAPva/httpretty/setup.py", line 98, in <module>
            tests_require=parse_requirements('development.txt'),
          File "/private/var/folders/49/9_0w6jk90gs5cs1mfg27xn0w0000gn/T/pip-build-ByAPva/httpretty/setup.py", line 62, in parse_requirements
            raise RuntimeError("Couldn't find the `requirements.txt' file :(")
        RuntimeError: Couldn't find the `requirements.txt' file :(
    
        ----------------------------------------
    Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/49/9_0w6jk90gs5cs1mfg27xn0w0000gn/T/pip-build-ByAPva/httpretty
    
    opened by miknight 11
  • Document global allow_net_connect flag

    Document global allow_net_connect flag

    I haven't found any place in the documentation where it is mentioned, that it is possible to globally disable network access:

    HTTPretty.allow_net_connect = False
    

    I also didn't find a good place to add it, thus I am leaving this issue here.

    opened by thigg 0
  • Fix build issues based on tests with the requirement of 2 miliseconds…

    Fix build issues based on tests with the requirement of 2 miliseconds…

    I want to fix #459 because of our build failures for openSUSE on s390x and arm. This Pull Request is covering all related tests with the requirement of 2 miliseconds, which are failing at the moment.

    Signed-off-by: Sarah Julia Kriesch [email protected]

    opened by skriesch 0
  • 1.1.4: Tests are failing on s390x because of

    1.1.4: Tests are failing on s390x because of "did not run within two miliseconds"

    I am building httpretty for the mainframe architecture s390x based on openSUSE Tumbleweed. There are some failing tests:

    
    [  272s] =================================== FAILURES ===================================
    [  272s] ______________________________ test_read_timeout _______________________________
    [  272s] 
    [  272s] self = <sure.AssertionBuilder object at 0x3ff9a9b1550>, args = (0.2,), kw = {}
    [  272s] 
    [  272s]     @wraps(func)
    [  272s]     def wrapper(self, *args, **kw):
    [  272s]         try:
    [  272s] >           value = func(self, *args, **kw)
    [  272s] 
    [  272s] /usr/lib/python3.8/site-packages/sure/__init__.py:408: 
    [  272s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
    [  272s] 
    [  272s] self = <sure.AssertionBuilder object at 0x3ff9a9b1550>, dest = 0.2
    [  272s] 
    [  272s]     @assertionmethod
    [  272s]     def lower_than(self, dest):
    [  272s]         if self.negative:
    [  272s]             msg = "expected `{0}` to not be lower than `{1}`".format(self.obj, dest)
    [  272s]     
    [  272s]             assert not self.obj < dest, msg
    [  272s]     
    [  272s]         else:
    [  272s]             msg = "expected `{0}` to be lower than `{1}`".format(self.obj, dest)
    [  272s] >           assert self.obj < dest, msg
    [  272s] E           AssertionError: expected `0.2305901050567627` to be lower than `0.2`
    [  272s] 
    [  272s] /usr/lib/python3.8/site-packages/sure/__init__.py:835: AssertionError
    [  272s] 
    [  272s] During handling of the above exception, another exception occurred:
    [  272s] 
    [  272s]     @httprettified(verbose=True, allow_net_connect=False)
    [  272s]     def test_read_timeout():
    [  272s]         "#430 httpretty should respect read timeout"
    [  272s]         event = Event()
    [  272s]         uri = "http://example.com"
    [  272s]     
    [  272s]         #  Given that I register a uri with a callback body that delays 10 seconds
    [  272s]         wait_seconds = 10
    [  272s]     
    [  272s]         def my_callback(request, url, headers):
    [  272s]             event.wait(wait_seconds)
    [  272s]             return 200, headers, "Received"
    [  272s]     
    [  272s]         HTTPretty.register_uri(HTTPretty.GET, uri, body=my_callback)
    [  272s]     
    [  272s]         # And I use a thread pool with 1 TCP connection max
    [  272s]         max_connections = 1
    [  272s]         request = http(max_connections)
    [  272s]         started_at = time.time()
    [  272s]         # When I make an HTTP request with a read timeout of 0.1 and an indefinite connect timeout
    [  272s]         when_called = request.get.when.called_with(uri, timeout=(None, 0.1))
    [  272s]     
    [  272s]         # Then the request should have raised a connection timeout
    [  272s]         when_called.should.have.raised(ReadTimeout)
    [  272s]     
    [  272s]         # And the total execution time should be less than 0.2 seconds
    [  272s]         event.set()
    [  272s]         total_time = time.time() - started_at
    [  272s] >       total_time.should.be.lower_than(0.2)
    [  272s] 
    [  272s] tests/bugfixes/nosetests/test_430_respect_timeout.py:54: 
    [  272s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
    [  272s] 
    [  272s] self = <sure.AssertionBuilder object at 0x3ff9a9b1550>, args = (0.2,), kw = {}
    [  272s] 
    [  272s]     @wraps(func)
    [  272s]     def wrapper(self, *args, **kw):
    [  272s]         try:
    [  272s]             value = func(self, *args, **kw)
    [  272s]         except AssertionError as e:
    [  272s] >           raise AssertionError(e)
    [  272s] E           AssertionError: expected `0.2305901050567627` to be lower than `0.2`
    [  272s] 
    [  272s] /usr/lib/python3.8/site-packages/sure/__init__.py:410: AssertionError
    [  272s] ____________________ test_rotating_responses_with_httplib2 _____________________
    [  272s] 
    [  272s] args = (), kw = {}, start = datetime.datetime(2022, 10, 25, 13, 3, 13, 960550)
    [  272s] end = datetime.datetime(2022, 10, 25, 13, 3, 14, 342034)
    [  272s] delta = datetime.timedelta(microseconds=381484), took = 3814.84
    [  272s] 
    [  272s]     def wrap(*args, **kw):
    [  272s]         start = datetime.utcnow()
    [  272s]     
    [  272s]         try:
    [  272s]             func(start, *args, **kw)
    [  272s]         except TypeError as e:
    [  272s]             if PY2:
    [  272s]                 # PY2 has different error message
    [  272s]                 fmt = "{0}() takes no arguments"
    [  272s]             else:
    [  272s]                 fmt = "{0}() takes 0 positional arguments but 1 was given"
    [  272s]             err = text_type(e)
    [  272s]             if fmt.format(func.__name__) in err:
    [  272s]                 func(*args, **kw)
    [  272s]             else:
    [  272s]                 exc.append(traceback.format_exc())
    [  272s]     
    [  272s]         except Exception as e:
    [  272s]             exc.append(traceback.format_exc())
    [  272s]     
    [  272s]         end = datetime.utcnow()
    [  272s]         delta = end - start
    [  272s]         took = convert_to(delta.microseconds)
    [  272s]         print(took, timeout)
    [  272s] >       assert took < timeout, "%s did not run within %s %s" % (
    [  272s]             func.__name__,
    [  272s]             word,
    [  272s]             unit,
    [  272s]         )
    [  272s] E       AssertionError: test_rotating_responses_with_httplib2 did not run within two miliseconds
    [  272s] 
    [  272s] /usr/lib/python3.8/site-packages/sure/__init__.py:217: AssertionError
    [  272s] ----------------------------- Captured stdout call -----------------------------
    [  272s] 3814.84 2000
    [  272s] ____________________________ test_callback_response ____________________________
    [  272s] 
    [  272s] args = (), kw = {}, start = datetime.datetime(2022, 10, 25, 13, 3, 14, 370477)
    [  272s] end = datetime.datetime(2022, 10, 25, 13, 3, 14, 611931)
    [  272s] delta = datetime.timedelta(microseconds=241454), took = 2414.54
    [  272s] 
    [  272s]     def wrap(*args, **kw):
    [  272s]         start = datetime.utcnow()
    [  272s]     
    [  272s]         try:
    [  272s]             func(start, *args, **kw)
    [  272s]         except TypeError as e:
    [  272s]             if PY2:
    [  272s]                 # PY2 has different error message
    [  272s]                 fmt = "{0}() takes no arguments"
    [  272s]             else:
    [  272s]                 fmt = "{0}() takes 0 positional arguments but 1 was given"
    [  272s]             err = text_type(e)
    [  272s]             if fmt.format(func.__name__) in err:
    [  272s]                 func(*args, **kw)
    [  272s]             else:
    [  272s]                 exc.append(traceback.format_exc())
    [  272s]     
    [  272s]         except Exception as e:
    [  272s]             exc.append(traceback.format_exc())
    [  272s]     
    [  272s]         end = datetime.utcnow()
    [  272s]         delta = end - start
    [  272s]         took = convert_to(delta.microseconds)
    [  272s]         print(took, timeout)
    [  272s] >       assert took < timeout, "%s did not run within %s %s" % (
    [  272s]             func.__name__,
    [  272s]             word,
    [  272s]             unit,
    [  272s]         )
    [  272s] E       AssertionError: test_callback_response did not run within two miliseconds
    [  272s] 
    [  272s] /usr/lib/python3.8/site-packages/sure/__init__.py:217: AssertionError
    [  272s] ----------------------------- Captured stdout call -----------------------------
    [  272s] 2414.54 2000
    [  272s] ____________________ test_rotating_responses_with_requests _____________________
    [  272s] 
    [  272s] args = (), kw = {}, start = datetime.datetime(2022, 10, 25, 13, 3, 15, 247484)
    [  272s] end = datetime.datetime(2022, 10, 25, 13, 3, 15, 508520)
    [  272s] delta = datetime.timedelta(microseconds=261036), took = 2610.36
    [  272s] 
    [  272s]     def wrap(*args, **kw):
    [  272s]         start = datetime.utcnow()
    [  272s]     
    [  272s]         try:
    [  272s]             func(start, *args, **kw)
    [  272s]         except TypeError as e:
    [  272s]             if PY2:
    [  272s]                 # PY2 has different error message
    [  272s]                 fmt = "{0}() takes no arguments"
    [  272s]             else:
    [  272s]                 fmt = "{0}() takes 0 positional arguments but 1 was given"
    [  272s]             err = text_type(e)
    [  272s]             if fmt.format(func.__name__) in err:
    [  272s]                 func(*args, **kw)
    [  272s]             else:
    [  272s]                 exc.append(traceback.format_exc())
    [  272s]     
    [  272s]         except Exception as e:
    [  272s]             exc.append(traceback.format_exc())
    [  272s]     
    [  272s]         end = datetime.utcnow()
    [  272s]         delta = end - start
    [  272s]         took = convert_to(delta.microseconds)
    [  272s]         print(took, timeout)
    [  272s] >       assert took < timeout, "%s did not run within %s %s" % (
    [  272s]             func.__name__,
    [  272s]             word,
    [  272s]             unit,
    [  272s]         )
    [  272s] E       AssertionError: test_rotating_responses_with_requests did not run within two miliseconds
    [  272s] 
    [  272s] /usr/lib/python3.8/site-packages/sure/__init__.py:217: AssertionError
    [  272s] ----------------------------- Captured stdout call -----------------------------
    [  272s] 2610.36 2000
    [  272s] ________________________ test_can_inspect_last_request _________________________
    [  272s] 
    [  272s] args = (), kw = {}, start = datetime.datetime(2022, 10, 25, 13, 3, 15, 999488)
    [  272s] end = datetime.datetime(2022, 10, 25, 13, 3, 16, 298155)
    [  272s] delta = datetime.timedelta(microseconds=298667), took = 2986.67
    [  272s] 
    [  272s]     def wrap(*args, **kw):
    [  272s]         start = datetime.utcnow()
    [  272s]     
    [  272s]         try:
    [  272s]             func(start, *args, **kw)
    [  272s]         except TypeError as e:
    [  272s]             if PY2:
    [  272s]                 # PY2 has different error message
    [  272s]                 fmt = "{0}() takes no arguments"
    [  272s]             else:
    [  272s]                 fmt = "{0}() takes 0 positional arguments but 1 was given"
    [  272s]             err = text_type(e)
    [  272s]             if fmt.format(func.__name__) in err:
    [  272s]                 func(*args, **kw)
    [  272s]             else:
    [  272s]                 exc.append(traceback.format_exc())
    [  272s]     
    [  272s]         except Exception as e:
    [  272s]             exc.append(traceback.format_exc())
    [  272s]     
    [  272s]         end = datetime.utcnow()
    [  272s]         delta = end - start
    [  272s]         took = convert_to(delta.microseconds)
    [  272s]         print(took, timeout)
    [  272s] >       assert took < timeout, "%s did not run within %s %s" % (
    [  272s]             func.__name__,
    [  272s]             word,
    [  272s]             unit,
    [  272s]         )
    [  272s] E       AssertionError: test_can_inspect_last_request did not run within two miliseconds
    [  272s] 
    [  272s] /usr/lib/python3.8/site-packages/sure/__init__.py:217: AssertionError
    [  272s] ----------------------------- Captured stdout call -----------------------------
    [  272s] 2986.67 2000
    [  272s] _____ test_httpretty_should_support_a_list_of_successive_responses_urllib2 _____
    [  272s] 
    [  272s] args = (), kw = {}, start = datetime.datetime(2022, 10, 25, 13, 3, 17, 834381)
    [  272s] end = datetime.datetime(2022, 10, 25, 13, 3, 18, 666219)
    [  272s] delta = datetime.timedelta(microseconds=831838), took = 8318.38
    [  272s] 
    [  272s]     def wrap(*args, **kw):
    [  272s]         start = datetime.utcnow()
    [  272s]     
    [  272s]         try:
    [  272s]             func(start, *args, **kw)
    [  272s]         except TypeError as e:
    [  272s]             if PY2:
    [  272s]                 # PY2 has different error message
    [  272s]                 fmt = "{0}() takes no arguments"
    [  272s]             else:
    [  272s]                 fmt = "{0}() takes 0 positional arguments but 1 was given"
    [  272s]             err = text_type(e)
    [  272s]             if fmt.format(func.__name__) in err:
    [  272s]                 func(*args, **kw)
    [  272s]             else:
    [  272s]                 exc.append(traceback.format_exc())
    [  272s]     
    [  272s]         except Exception as e:
    [  272s]             exc.append(traceback.format_exc())
    [  272s]     
    [  272s]         end = datetime.utcnow()
    [  272s]         delta = end - start
    [  272s]         took = convert_to(delta.microseconds)
    [  272s]         print(took, timeout)
    [  272s] >       assert took < timeout, "%s did not run within %s %s" % (
    [  272s]             func.__name__,
    [  272s]             word,
    [  272s]             unit,
    [  272s]         )
    [  272s] E       AssertionError: test_httpretty_should_support_a_list_of_successive_responses_urllib2 did not run within two miliseconds
    [  272s] 
    [  272s] /usr/lib/python3.8/site-packages/sure/__init__.py:217: AssertionError
    

    It seems, that max. 0,2 is made for one test, but the test is receiving 0.2305901050567627. That will be used also for the timeout, which is the reason for the error messages:

    • AssertionError: expected 0.2305901050567627 to be lower than 0.2
    • AssertionError: test_rotating_responses_with_httplib2 did not run within two miliseconds
    • AssertionError: test_callback_response did not run within two miliseconds
    opened by skriesch 1
  • Typing error when using callback as body

    Typing error when using callback as body

    Per the docs passing a callback as body with register_uri causes:

    (function) exceptionCallback: (request: Unknown, uri: Unknown, headers: Unknown) -> NoReturn
    Argument of type "(request: Unknown, uri: Unknown, headers: Unknown) -> NoReturn" cannot be assigned to parameter "body" of type "str" in function "register_uri"
      "object" is incompatible with "str"```
    

    I see a little bit of typing has made its way in, so am I good to make a PR adding types here?

    opened by davetapley 0
  • 1.1.4: sphinx warnings `reference target not found`

    1.1.4: sphinx warnings `reference target not found`

    On building my packages I'm using sphinx-build command with -n switch which shows warmings about missing references. These are not critical issues. Here is the output with warnings:

    + /usr/bin/sphinx-build -n -T -b man docs/source build/sphinx/man
    Running Sphinx v4.5.0
    making output directory... done
    loading intersphinx inventory from https://docs.python.org/3/objects.inv...
    loading intersphinx inventory from https://httplib2.readthedocs.io/en/latest/objects.inv...
    loading intersphinx inventory from https://requests.readthedocs.io/en/master/objects.inv...
    loading intersphinx inventory from https://urllib3.readthedocs.io/en/latest/objects.inv...
    intersphinx inventory has moved: https://requests.readthedocs.io/en/master/objects.inv -> https://docs.python-requests.org/en/master/objects.inv
    [autosummary] generating autosummary for: acks.rst, api.rst, changelog.rst, contributing.rst, guides.rst, index.rst, introduction.rst
    building [mo]: targets for 0 po files that are out of date
    building [man]: all manpages
    updating environment: [new config] 7 added, 0 changed, 0 removed
    reading sources... [100%] introduction
    looking for now-outdated files... none found
    pickling environment... done
    checking consistency... done
    writing... python-httpretty.3 { introduction guides acks api contributing changelog } /home/tkloczko/rpmbuild/BUILD/HTTPretty-1.1.4/docs/source/introduction.rst:170: WARNING: py:class reference target not found: mock.Mock
    /home/tkloczko/rpmbuild/BUILD/HTTPretty-1.1.4/docs/source/guides.rst:65: WARNING: py:class reference target not found: st
    /home/tkloczko/rpmbuild/BUILD/HTTPretty-1.1.4/docs/source/../../httpretty/core.py:docstring of httpretty.core.httpretty.enable:26: WARNING: py:class reference target not found: httpretty.enabled
    /home/tkloczko/rpmbuild/BUILD/HTTPretty-1.1.4/docs/source/../../httpretty/core.py:docstring of httpretty.core.httpretty.disable:18: WARNING: py:meth reference target not found: httpretty.core.reset
    /home/tkloczko/rpmbuild/BUILD/HTTPretty-1.1.4/docs/source/../../httpretty/core.py:docstring of httpretty.core.httprettified:3: WARNING: py:func reference target not found: httpretty.activate
    /home/tkloczko/rpmbuild/BUILD/HTTPretty-1.1.4/docs/source/../../httpretty/core.py:docstring of httpretty.core.httprettized:3: WARNING: py:func reference target not found: httpretty.enabled
    /home/tkloczko/rpmbuild/BUILD/HTTPretty-1.1.4/docs/source/../../httpretty/core.py:docstring of httpretty.core.Entry:: WARNING: py:class reference target not found: re.Pattern
    /home/tkloczko/rpmbuild/BUILD/HTTPretty-1.1.4/docs/source/../../httpretty/core.py:docstring of httpretty.core.Entry:: WARNING: py:class reference target not found: httpretty.Entry
    /home/tkloczko/rpmbuild/BUILD/HTTPretty-1.1.4/docs/source/../../httpretty/core.py:docstring of httpretty.core.Entry:: WARNING: py:class reference target not found: re.Pattern
    /home/tkloczko/rpmbuild/BUILD/HTTPretty-1.1.4/docs/source/../../httpretty/core.py:docstring of httpretty.core.Entry:: WARNING: py:class reference target not found: httpretty.Entry
    /home/tkloczko/rpmbuild/BUILD/HTTPretty-1.1.4/docs/source/../../httpretty/core.py:docstring of httpretty.core.httprettified:3: WARNING: py:func reference target not found: httpretty.activate
    /home/tkloczko/rpmbuild/BUILD/HTTPretty-1.1.4/docs/source/../../httpretty/core.py:docstring of httpretty.core.httprettized:3: WARNING: py:func reference target not found: httpretty.enabled
    /home/tkloczko/rpmbuild/BUILD/HTTPretty-1.1.4/docs/source/../../httpretty/core.py:docstring of httpretty.core.httpretty.Response:: WARNING: py:class reference target not found: re.Pattern
    /home/tkloczko/rpmbuild/BUILD/HTTPretty-1.1.4/docs/source/../../httpretty/core.py:docstring of httpretty.core.httpretty.Response:: WARNING: py:class reference target not found: httpretty.Entry
    /home/tkloczko/rpmbuild/BUILD/HTTPretty-1.1.4/docs/source/../../httpretty/core.py:docstring of httpretty.core.httpretty.disable:18: WARNING: py:meth reference target not found: httpretty.core.reset
    /home/tkloczko/rpmbuild/BUILD/HTTPretty-1.1.4/docs/source/../../httpretty/core.py:docstring of httpretty.core.httpretty.enable:26: WARNING: py:class reference target not found: httpretty.enabled
    /home/tkloczko/rpmbuild/BUILD/HTTPretty-1.1.4/docs/source/../../httpretty/core.py:docstring of httpretty.core.httpretty.match_http_address:3: WARNING: py:class reference target not found: httpretty.core.URLMatcher
    /home/tkloczko/rpmbuild/BUILD/HTTPretty-1.1.4/docs/source/../../httpretty/core.py:docstring of httpretty.core.httpretty.match_https_hostname:2: WARNING: py:class reference target not found: httpretty.core.URLMatcher
    /home/tkloczko/rpmbuild/BUILD/HTTPretty-1.1.4/docs/source/../../httpretty/core.py:docstring of httpretty.core.httpretty.match_uriinfo:2: WARNING: py:class reference target not found: httpretty.core.URLMatcher
    /home/tkloczko/rpmbuild/BUILD/HTTPretty-1.1.4/docs/source/changelog.rst:22: WARNING: py:mod reference target not found: urllib3
    WARNING: asciinema: unsupported output format (node skipped)
    done
    build succeeded, 21 warnings.
    

    You can peak on https://github.com/latchset/jwcrypto/pull/289 https://github.com/click-contrib/sphinx-click/commit/abc31069.

    opened by kloczek 0
Owner
Gabriel Falcão
Software Engineer, New York Times
Gabriel Falcão
A mocking library for requests

httmock A mocking library for requests for Python 2.7 and 3.4+. Installation pip install httmock Or, if you are a Gentoo user: emerge dev-python/httm

Patryk Zawadzki 452 Dec 28, 2022
Python HTTP Server

Python HTTP Server Preview Languange and Code Editor: How to run? Download the zip first. Open the http.py and wait 1-2 seconds. You will see __pycach

SonLyte 16 Oct 21, 2021
Automatically mock your HTTP interactions to simplify and speed up testing

VCR.py ?? This is a Python version of Ruby's VCR library. Source code https://github.com/kevin1024/vcrpy Documentation https://vcrpy.readthedocs.io/ R

Kevin McCarthy 2.3k Jan 1, 2023
gunicorn 'Green Unicorn' is a WSGI HTTP Server for UNIX, fast clients and sleepy applications.

Gunicorn Gunicorn 'Green Unicorn' is a Python WSGI HTTP Server for UNIX. It's a pre-fork worker model ported from Ruby's Unicorn project. The Gunicorn

Benoit Chesneau 8.7k Jan 1, 2023
An HTTP server to easily download and upload files.

httpsweet An HTTP server to easily download and upload files. It was created with flexibility in mind, allowing be used in many different situations,

Eloy 17 Dec 23, 2022
Scalable user load testing tool written in Python

Locust Locust is an easy to use, scriptable and scalable performance testing tool. You define the behaviour of your users in regular Python code, inst

Locust.io 20.4k Jan 8, 2023
A modern API testing tool for web applications built with Open API and GraphQL specifications.

Schemathesis Schemathesis is a modern API testing tool for web applications built with Open API and GraphQL specifications. It reads the application s

Schemathesis.io 1.6k Jan 4, 2023
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
A cross-platform GUI automation Python module for human beings. Used to programmatically control the mouse & keyboard.

PyAutoGUI PyAutoGUI is a cross-platform GUI automation Python module for human beings. Used to programmatically control the mouse & keyboard. pip inst

Al Sweigart 7.6k Jan 1, 2023
splinter - python test framework for web applications

splinter - python tool for testing web applications splinter is an open source tool for testing web applications using Python. It lets you automate br

Cobra Team 2.6k Dec 27, 2022
Let your Python tests travel through time

FreezeGun: Let your Python tests travel through time FreezeGun is a library that allows your Python tests to travel through time by mocking the dateti

Steve Pulec 3.5k Jan 9, 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 5, 2023
Mixer -- Is a fixtures replacement. Supported Django, Flask, SqlAlchemy and custom python objects.

The Mixer is a helper to generate instances of Django or SQLAlchemy models. It's useful for testing and fixture replacement. Fast and convenient test-

Kirill Klenov 871 Dec 25, 2022
Faker is a Python package that generates fake data for you.

Faker is a Python package that generates fake data for you. Whether you need to bootstrap your database, create good-looking XML documents, fill-in yo

Daniele Faraglia 15.2k Jan 1, 2023
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 Jan 1, 2023
Coroutine-based concurrency library for Python

gevent Read the documentation online at http://www.gevent.org. Post issues on the bug tracker, discuss and ask open ended questions on the mailing lis

gevent 5.9k Dec 28, 2022
Radically simplified static file serving for Python web apps

WhiteNoise Radically simplified static file serving for Python web apps With a couple of lines of config WhiteNoise allows your web app to serve its o

Dave Evans 2.1k Jan 8, 2023
livereload server in python (MAINTAINERS NEEDED)

LiveReload Reload webpages on changes, without hitting refresh in your browser. Installation python-livereload is for web developers who know Python,

Hsiaoming Yang 977 Dec 14, 2022
A screamingly fast Python 2/3 WSGI server written in C.

bjoern: Fast And Ultra-Lightweight HTTP/1.1 WSGI Server A screamingly fast, ultra-lightweight WSGI server for CPython 2 and CPython 3, written in C us

Jonas Haag 2.9k Dec 21, 2022