| Commit message (Collapse) | Author | Age | Files | Lines |
| | |
|
| |
|
|
|
|
|
|
| |
* Ignore IDE metadata
* Python 2.6 is EOL and was dropped in 2015
* Use automatic formatters
|
| |\
| |
| | |
Fixed an error when "Content-Length" is not int like
|
| | | |
|
| | | |
|
| | | |
|
| |\ \
| | |
| | | |
Decorate unittest.TestCase setUp/tearDown methods
|
| | |/
| |
| |
| |
| |
| |
| | |
When the class being decorated by httprettified inherits from
unittest.TestCase, enable HTTPretty in setUp rather than decorating each
test separately. This lets users register their HTTP mock entries in
setUp if they want.
|
| | | |
|
| | | |
|
| | | |
|
| | | |
|
| | | |
|
| | |
| |
| |
| |
| |
| |
| |
| |
| | |
Matchers are stored in a dictionary and are checked in an unpredictable
order. This can be a problem when multiple matchers match the same
URI--for example, when using multiple regex matchers. This patch adds an
optional an optional priority argument to register_uri to resolve this
ambiguity. When matching a URI, matchers are sorted descending by
priority, and the first match is used.
|
| |\ \
| | |
| | | |
Allow_net_connect, prevent real connections
|
| | |/
| |
| |
| |
| |
| |
| | |
Users can prevent all real connections by assigning
HTTPretty.allow_net_connect = False.
When a connection is blocked, UnmockedError is raised instead.
|
| |/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Reopens https://github.com/gabrielfalcao/HTTPretty/pull/145. Reopened as a new PR because Travis didn't seem to be running the correct tests. Removed the irrelevant changes, such as PEP8 and the `self.truesock.settimeout(0)` change.
HTTPretty does not behave correctly when using regex matching, HTTPS and custom ports. When this scenario is triggered, a timeout/max retries exceeded error occurs.
To duplicate run:
```python
@httpretty.activate
def exceed_max_retries_with_custom_port_and_https():
HTTPretty.register_uri(
HTTPretty.GET,
re.compile('https://api.yipit.com:1234/v1/deal;brand=(?P<brand_name>\w+)'),
body='meow'
)
uri = 'https://api.yipit.com:1234/v1/deal;brand=gap?first_name=chuck&last_name=norris'
response = requests.get(uri)
return response.content
```
Cause
--
The combination of a regex URI, custom port, and HTTPS causes HTTPretty to get stuck at https://github.com/gabrielfalcao/HTTPretty/blob/2e814635fff916d3a8c246ca010245362266c89f/httpretty/core.py#L323 and eventually raise this error:
```
ConnectionError: HTTPSConnectionPool(host='api.yipit.com', port=1234): Max retries exceeded with url: /v1/deal;brand=gap?first_name=chuck&last_name=norris (Caused by <class 'socket.error'>: [Errno 36] Operation now in progress).
```
This error happens because URI schema's are reconstructed incorrectly during the URI matching.
This should fail (http != https), but it does not!
```python
@httpretty.activate
def broken_reconstruction_of_uri_schema():
uri = 'api.yipit.com:1234/v1/deal'
HTTPretty.register_uri(HTTPretty.GET,
'https://' + uri,
body=lambda method, uri, headers: [200, headers, uri]
)
response = requests.get(uri)
expect(response.text).to.equal('http://' + uri) # incorrect!
```
Solution
--
To correct the internal confusion between HTTP and HTTPS ports, we need to separate the two in our DEFAULT/POTENTIAL PORTS lists. When URIMatcher encounters a non-regex URI it uses URIInfo.from_uri to add
the URIs port to the known ports. This behavior is now added for regex URIs.
We now use the DEFAULT_PORTS lists in HTTPretty.reset() to reset the POTENTIAL_PORTS lists. Also, to avoid using the global keyword, we do an in-place reset with intersection_update.
Added the following tests:
- test_httpretty_should_work_with_non_standard_ports
- test_httpretty_reset_by_switching_protocols_for_same_port
- test_httpretty_should_allow_registering_regexes_with_port_and_give_a_proper_match_to_the_callback
|
| | |
|
| |
|
|
|
|
| |
test_httpretty_should_allow_registering_regexes_with_streaming_responses()
This was cause by the use of text strings instead of bytes.
|
| |
|
|
|
|
|
|
| |
* in record_request, do not try to call json.dumps() on a dict() containing
bytes;
* in test_recording_calls(), do not hardcode the expected version of Tornado.
There was a json.dumps(some_dict) and soe_dict had bytes values
|
| | |
|
| |
|
|
|
| |
CPython does not guarantee that the id() of integers will be the same
and they should therefore be tested with standard equality.
|
| |
|
|
|
|
|
| |
Tests should be run against the latest versions of libraries. Initially
there was going to be a lower bound on requirements but it is unlikely
that a situation will arise where a version is too out of date and can
be added back then rather than having arbitrary minimums.
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| |
|
|
| |
fake server's port from POTENTIAL_HTTP_PORTS in the end of the test
|
| | |
|
| | |
|
| | |
|
| |\
| |
| | |
Don't duplicate http ports number
|
| | |
| |
| |
| |
| | |
Use a set instead of a list to store ports in the POTENTIAL_HTTP_PORTS.
Restore it to its initial value every tests that modify it.
|
| |/
|
|
| |
If you want to register one URI with multiple querystrings, you can pass the "match_querystring" attribute to register_uri.
|
| |
|
|
|
|
| |
HTTPretty is about patching the socket for port 80 and 443 only, so,
others ports may be mocked by another tool.
DNS Client, for exemple should continue to works with the HTTPretty.
|
| | |
|
| |\
| |
| | |
Remove 2.x style unicode literals
|
| | | |
|
| | | |
|
| |/ |
|
| | |
|
| | |
|
| | |
|
| |\
| |
| | |
Remove querystring from full_url() and thus url regex matching (attempt #2)
|
| | | |
|
| | | |
|
| |/ |
|