Giter Site home page Giter Site logo

Comments (3)

gabrielfalcao avatar gabrielfalcao commented on May 18, 2024

Hi @emillon,

it looks like there are no problems at all, both HTTPretty and requests are working fine.

The "problem" is that requests always follow redirects automatically, so you would need to do something like this:

#!/usr/bin/env python
# -*- coding: utf-8 -*-
import requests
from sure import expect
from httpretty import httprettified, HTTPretty


@httprettified
def test_expand_tiny():
    url = 'http://tinyurl.com/deadbeef'
    target = 'http://google.fr/'

    HTTPretty.register_uri(HTTPretty.GET, url,
                           status=301,
                           location=target)

    HTTPretty.register_uri(HTTPretty.GET, target,
                           status=200,
                           body="it works!")

    r = requests.get(url)
    expect(r.url).to.equal(target)
    expect(r.text).to.equal("it works!")

from httpretty.

emillon avatar emillon commented on May 18, 2024

Oh, my bad. Does it mean that when httpretty is enabled, every HTTP request through socket will be blocked if there's no handler for it ? That's exactly what I need. Thanks !

from httpretty.

gabrielfalcao avatar gabrielfalcao commented on May 18, 2024

No, HTTPretty will send unexpected requests to a real socket.
😄

from httpretty.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.