summaryrefslogtreecommitdiff
path: root/httpretty
Commit message (Collapse)AuthorAgeFilesLines
...
* | | | Disable sendall/recv magic for non-http(s) socketsMarco Paolini2015-02-271-0/+2
| | | | | | | | | | | | | | | | Fixes #184
* | | | Merge pull request #216 from frankamp/masterGabriel Falcão2015-02-211-11/+13
|\ \ \ \ | | | | | | | | | | The worst PR that fixes all the things
| * | | | removing bad setsockopt implementation and replacing with a passthrough to ↵Josh Frankamp2015-02-081-11/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | the socket setting the socket to blocking in the case of 'real' socket forcing the close command on the fd to close the socket replacing the fd at the start of each sendall
* | | | | New release: 0.8.5Gabriel Falcão2015-02-191-1/+1
| | | | |
* | | | | fixing build in python 3.4Gabriel Falcão2015-02-122-3/+5
| | | | |
* | | | | not building against pypyGabriel Falcão2015-02-121-0/+4
|/ / / /
* | | | New release: 0.8.4Gabriel Falcão2015-02-031-1/+1
| | | |
* | | | Fix for https://github.com/gabrielfalcao/HTTPretty/issues/206Andres Riancho2015-01-071-2/+11
|/ / /
* | | Merge pull request #170 from chris-martin/disallow-real-connectionsGabriel Falcão2014-12-113-13/+36
|\ \ \ | |/ / |/| | Allow_net_connect, prevent real connections
| * | Allow_net_connect, prevent real connections (#157)Chris Martin2014-05-233-13/+36
| |/ | | | | | | | | | | | | Users can prevent all real connections by assigning HTTPretty.allow_net_connect = False. When a connection is blocked, UnmockedError is raised instead.
* | New release: 0.8.30.8.3Gabriel Falcao2014-06-191-1/+1
| |
* | New release: 0.8.20.8.2Gabriel Falcao2014-06-191-1/+1
| |
* | New release: 0.8.10.8.1Gabriel Falcao2014-06-191-1/+1
| |
* | Fix bug that occurs when using custom schema/port/regexLuqmaan2014-04-031-8/+24
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Unit test for mocking of octet stream and fix to the codeMatt Millar2014-03-141-1/+1
|
* New release: 0.8.00.8.0Gabriel Falcao2014-02-031-1/+1
|
* Python 3: fix ↵Cyril Roelandt2014-01-211-2/+2
| | | | | | test_httpretty_should_allow_registering_regexes_with_streaming_responses() This was cause by the use of text strings instead of bytes.
* Python 3: fix encoding issueCyril Roelandt2014-01-211-0/+4
| | | | | | In Python 3, the parse_request() method uses iso-8859-1 to decode the path, but not in Python 2. This causes test failures in Python 3. Fix that by encoding the path back to iso-8859-1.
* Python3: Fix test_recording_calls()Cyril Roelandt2014-01-211-2/+2
| | | | | | | | * 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
* Python 3: fix parse_requestline().Cyril Roelandt2014-01-212-12/+13
| | | | | The parse_requestline() function needs a text string as an input. In Python 3, it had bytes.
* Python 3: cast return values of map() to list().Cyril Roelandt2014-01-211-3/+3
| | | | This ensures Python 3 compatibility.
* Python 3: Pass bytes to sendall() and friends.Cyril Roelandt2014-01-211-1/+1
| | | | Thanks to Victor Stinner for this patch.
* Python 3: fix parse_request_body()Cyril Roelandt2014-01-211-0/+1
| | | | Return a decoded string rather than bytes.
* Reset POTENTIAL_HTTP_PORTS with resetJamie Lennox2014-01-151-0/+2
| | | | | | | | HTTPretty.reset removes all the HTTP mocks that are put in places. There is therefore no reason to keep around potential http ports that are not in the current list of mocks. Therefore we should reset that set as well when we reset the mocks.
* Remove bytes in calls to str.split()Cyril Roelandt2013-12-181-2/+2
| | | | | | | | | | | | | | | | | | | It is useless to write foo.split(b'bar') rather than foo.split(bar). In Python 2, this is exactly the same thing: >>> 'fooXbar'.split('X') ['foo', 'bar'] >>> 'fooXbar'.split(b'X') ['foo', 'bar'] In Python 3, using bytes in split() is an error: >>> 'fooXbar'.split('X') ['foo', 'bar'] >>> 'fooXbar'.split(b'X') Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: Can't convert 'bytes' object to str implicitly
* New release: 0.7.1Gabriel Falcao2013-11-211-1/+1
|
* Merge pull request #115 from melor/py33Gabriel Falcão2013-11-212-4/+14
|\ | | | | core: fix for working with python 3.3
| * core: fix for working with python 3.3Mika Eloranta2013-10-232-4/+14
| | | | | | | | | | | | | | | | | | | | The unfixed parse_querystring() raises the following exception in Python 3.3: TypeError: Type str doesn't support the buffer API Also removed iteritems() as it is deprecated and no longer supported in Python 3.x
* | Replaced dynamic module attributes with actual references.Simon König2013-10-271-6/+15
|/
* New release: 0.7.0Gabriel Falcao2013-10-071-1/+1
|
* reaching 80% of unit test coverageGabriel Falcao2013-10-072-8/+9
|
* comment cleanupGabriel Falcao2013-10-071-4/+0
|
* refactoring sendallGabriel Falcao2013-10-071-17/+15
|
* more refactoringGabriel Falcao2013-10-071-7/+9
|
* more refactoringGabriel Falcao2013-10-071-2/+4
|
* more refactoringGabriel Falcao2013-10-041-11/+29
|
* Starting to refactor the core moduleGabriel Falcao2013-10-041-26/+86
|
* temporarily solving #42 in a ugly way. Ready to refactor some codeGabriel Falcao2013-10-031-2/+7
|
* fixing the POST callback being called twice. closes #100, but might regress #42Gabriel Falcao2013-10-031-9/+9
|
* teaching HTTPretty to playback recorded responses. refs #10Gabriel Falcao2013-10-011-0/+14
|
* teaching HTTPretty how to record requests. refs #10Gabriel Falcao2013-10-012-5/+58
|
* fixing bug when unicode query string had unicode chars. closes #36Gabriel Falcao2013-10-012-6/+19
|
* adding the CONNECT method. closes #85Gabriel Falcao2013-09-301-1/+2
|
* New release: 0.6.5Gabriel Falcao2013-09-301-1/+1
|
* Merge pull request #88 from toumorokoshi/parsed_postGabriel Falcão2013-09-291-1/+16
|\ | | | | Adding parsed_body parameter to simplify checks
| * fixing tests for python3Yusuke Tsutsumi2013-09-081-7/+8
| |
| * Adding parsed_body parameter to simplify checksYusuke Tsutsumi2013-07-291-0/+14
| | | | | | | | | | | | | | | | parsed_body attempts to parse the post body if it matches a compatible content type * content is returned unaltered if it's not a compatible type * content parses json if content-type type is application/json * content parse querystring params if content-type is application/x-www-form-urlencoded * if the value cannot be parsed for any reason, it is unaltered
* | Merge pull request #89 from Gandi/masterGabriel Falcão2013-09-291-3/+3
|\ \ | | | | | | Don't duplicate http ports number
| * | Don't duplicate http ports numberGuillaume Gauvrit2013-07-291-3/+3
| |/ | | | | | | | | 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.
* | Merge pull request #91 from imankulov/extended_apiGabriel Falcão2013-09-291-1/+1
|\ \ | | | | | | Expose httpretty.reset() to public API