Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.2 / 3....
  • LibreOffice 3.6.6 / 4.0.3
  • MPlayer 1.1.1
  • systemd 204
  • Arch Linux 2013.05.01
  • Blender 2.67
  • KDE Software Compilatio...
  • CrunchBang Linux Stable...
  • Elementary OS 0.1 / 0.2...
  • SystemRescueCd 3.6.0
  • Home > Linux > Programming > Libraries

    HTTPretty 0.5.13

    Download button

    No screenshots available
    Downloads: 128  Tell us about an update
    User Rating:
    Rated by:
    NOT RATED
    0 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Gabriel Falcao | More programs
    MIT/X Consortium Lic... / FREE
    July 2nd, 2011, 09:08 GMT
    ROOT / Programming / Libraries

     Read user reviews (0)  Refer to a friend  Subscribe

    HTTPretty description

    HTTP client mock for Python

    HTTPretty is a HTTP client mock library for Python 100% inspired on ruby's FakeWeb

    Motivation

    When building systems that access external resources such as RESTful webservices, XMLRPC or even simple HTTP requests, we stumble in the problem:

    "I'm gonna need to mock all those requests"

    It brings a lot of hassle, you will need to use a generic mocking tool, mess with scope and so on.

    The idea behind HTTPretty (how it works)

    HTTPretty monkey matches Python's socket core module, reimplementing the HTTP protocol, by mocking requests and responses.

    As for it works in this way, you don't need to worry what http library you're gonna use.

    HTTPretty will mock the response for you :) (and also give you the latest requests so that you can check them)

    Usage

    expecting a simple response body

    from httpretty import HTTPretty
    HTTPretty.register_uri(HTTPretty.GET, "http://globo.com/",
     body="The biggest portal in Brazil")

    fd = urllib2.urlopen('http://globo.com')
    got = fd.read()
    fd.close()

    print got


    :: output ::

    The biggest portal in Brazil

    mocking the status code

    HTTPretty.register_uri(HTTPretty.GET, "http://github.com/",
     body="here is the mocked body",
     status=201)

    fd = urllib2.urlopen('http://github.com')
    got = fd.read()
    fd.close()

    assert got == "here is the mocked body"
    assert fd.code == 201



    Product's homepage

    Requirements:

    · Python

      


    TAGS:

    HTTP client | Python library | HTTP | client | mock

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM