Comments (3)
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.
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.
No, HTTPretty will send unexpected requests to a real socket.
😄
from httpretty.
Related Issues (20)
- httpretty.errors.UnmockedError: Failed to socket.setblocking because because a real socket does not exist HOT 1
- 1.1.4: sphinx warnings `reference target not found`
- Typing error when using callback as body
- State of project HOT 1
- test_httpretty_should_handle_paths_starting_with_two_slashes needs update HOT 2
- 1.1.4: Tests are failing on s390x because of "did not run within two miliseconds" HOT 1
- Document global allow_net_connect flag HOT 1
- Request body isn't decoded when client specifies its charset
- Link headers Example does not work
- Reset should blank latest_requests? HOT 1
- FakeSockFile: `'super' object has no attribute 'flush'` HOT 1
- urllib3.contrib.pyopenssl is being deprecated
- Requests upgrade to v2.29.0 causes the test case test_httpretty_should_allow_registering_regexes_with_streaming_responses to fail
- Why httpretty.enabled(context manager) effect is getting reset after it encounter @httpretty.activate ? HOT 1
- Long response time when calling unmatched requests
- httpretty silently fails with Python 3.12
- tox testing fails: *** No rule to make target 'test'. Stop.
- Recording requests does not work for non-UTF8 data
- Does httpretty support multi-threading? HOT 1
- Is this repository still actively maintained? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from httpretty.