summaryrefslogtreecommitdiff
path: root/tests
Commit message (Collapse)AuthorAgeFilesLines
* typoGabriel Falcão2018-03-071-3/+4
|
* Update version classifiers (#329)Hugo2018-03-074-16/+16
| | | | | | | | * Ignore IDE metadata * Python 2.6 is EOL and was dropped in 2015 * Use automatic formatters
* Merge pull request #165 from akun/masterGabriel Falcão2017-02-161-0/+2
|\ | | | | Fixed an error when "Content-Length" is not int like
| * Fixed an error when "Content-Length" is not int likeakun2014-05-191-0/+2
| |
* | add a test for content-length header with callable bodyKonstantinos Koukopoulos2017-02-161-61/+20
| |
* | Squashed commit of the following:Andrew Gross2016-10-112-0/+100
| | | | | | | | | | | | | | | | | | | | | | | | | | | | commit 352339b3ee12e120d044340c075a32ddb6656e89 Author: Andrew Gross <andrew.w.gross@gmail.com> Date: Tue Oct 11 19:00:22 2016 -0400 Remove unused imports commit 226d294d9bdcb396a06c0df534ad94d56ccc8e86 Author: Andrew Gross <andrew.w.gross@gmail.com> Date: Tue Oct 11 18:54:20 2016 -0400 Patch out urllib monkeypatching when installed, adds tests for behavior
* | Update HTTP call recording to properly send headers being testedAndrew Gross2016-10-111-1/+5
| |
* | Merge pull request #169 from chris-martin/unittest_TestCase_decoratorGabriel Falcão2016-05-261-1/+68
|\ \ | | | | | | Decorate unittest.TestCase setUp/tearDown methods
| * | Decorate unittest.TestCase setUp/tearDown methodsChris Martin2014-05-231-1/+68
| |/ | | | | | | | | | | | | 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.
* | Merge pull request #285 from hufman/use_tempfileGabriel Falcão2016-05-262-6/+6
|\ \ | | | | | | Use a tempfile instead of a StringIO object
| * | Use a tempfile instead of a StringIO objectWalter Huf2016-02-032-6/+6
| | | | | | | | | | | | | | | | | | This provides a socket.fileno(), so libraries that call select.poll() work properly. Also supports mocking huge responses larger than memory, if needed.
* | | Merge pull request #287 from hufman/dynamic-content-lengthGabriel Falcão2016-05-261-0/+10
|\ \ \ | | | | | | | | Encode callable body length as str and not bytes
| * | | Encode callable body length as str and not bytesWalter Huf2016-02-061-0/+10
| |/ / | | | | | | | | | | | | | | | | | | The bytes() constructor, when given an integer, creates a bytes object of that length, instead of casting the number to a string representation. This change uses str() to cast the integer, and then relies on the later utf8() call to convert it to bytes.
* | | Use body and headers when recording upstream calls.Bogdan Hodorog2016-04-062-3/+12
|/ /
* | BF: PY3 etc -- no need to byte_type an in which later %s-ed, assume sending ↵Yaroslav Halchenko2015-12-151-3/+3
| | | | | | | | | | | | bytes registers bytes also adjusted bogus shebang to not be real
* | making the functional tests a bit more permissiveGabriel Falcão2015-12-141-6/+7
| |
* | attempt to disable httpretty in the current process before spawning a subprocessGabriel Falcão2015-12-141-4/+7
| |
* | ignoring error when IOLoop has already startedGabriel Falcão2015-12-141-1/+4
| |
* | revamping docs + testsGabriel Falcão2015-12-1312-67/+105
| |
* | Merge pull request #233 from jmcarp/matcher-priorityGabriel Falcão2015-07-291-0/+17
|\ \ | | | | | | Add priority argument to register_uri.
| * | Add priority argument to register_uri.Joshua Carp2015-03-131-0/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | | Fix py34 hangingBen Picolo2015-05-131-0/+24
| | |
* | | add httpretty.has_request() and testjsa2015-05-071-0/+7
|/ /
* | Update and test PR #208.Joshua Carp2015-02-271-9/+43
| | | | | | | | | | | | | | Resolve incompatibility between HTTPretty and MongoDB / pymongo (before patch, pymongo times out trying to read from socket, since truesock#recv was called in fakesocket#real_sendall). Make minor change to PR #208 for clarity, and fix breaking unit tests.
* | updating tests to reflect blocking underlying socketJosh Frankamp2015-02-161-15/+12
| |
* | Added test to reproduce https://github.com/gabrielfalcao/HTTPretty/issues/206Andres Riancho2015-01-071-0/+12
| |
* | Merge pull request #170 from chris-martin/disallow-real-connectionsGabriel Falcão2014-12-111-1/+68
|\ \ | | | | | | Allow_net_connect, prevent real connections
| * | Allow_net_connect, prevent real connections (#157)Chris Martin2014-05-231-1/+68
| |/ | | | | | | | | | | | | Users can prevent all real connections by assigning HTTPretty.allow_net_connect = False. When a connection is blocked, UnmockedError is raised instead.
* | Fix bug that occurs when using custom schema/port/regexLuqmaan2014-04-032-1/+153
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-0/+23
|
* Python3: use bytes where needed.Cyril Roelandt2014-01-211-4/+4
| | | | Bytes were needed in some place, instead of text strings.
* 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 test_request_stubs_internalsCyril Roelandt2014-01-211-5/+5
| | | | | | | In Python 2, dict(request.headers) will have all keys in lower case, while In Python 3, the capital letters will still be there. This is because of internal changes in the requests library. Let's use lower-case headers, so that this is not an issue.
* Python3: Fix test_recording_calls()Cyril Roelandt2014-01-211-1/+3
| | | | | | | | * 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: do not hardcode class name in test_request_stubs_internals().Cyril Roelandt2014-01-211-2/+5
| | | | | StringIO might be either 'StringIO.StringIO' or 'io.BytesIO' depending on the version of Python used. Do not hardcode the type in the test.
* Python 3: Pass bytes to sendall() and friends.Cyril Roelandt2014-01-211-21/+21
| | | | Thanks to Victor Stinner for this patch.
* Fix relative importCyril Roelandt2014-01-211-1/+1
|
* Fix test that checks ID rather than equalityJamie Lennox2014-01-151-2/+2
| | | | | CPython does not guarantee that the id() of integers will be the same and they should therefore be tested with standard equality.
* Free version requirementsJamie Lennox2014-01-141-1/+2
| | | | | | | 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.
* creating new docsGabriel Falcao2013-10-101-0/+9
|
* reaching 80% of unit test coverageGabriel Falcao2013-10-071-0/+12
|
* refactoring sendallGabriel Falcao2013-10-071-1/+110
|
* improving test serverGabriel Falcao2013-10-071-2/+9
|
* more refactoringGabriel Falcao2013-10-071-13/+88
|
* more refactoringGabriel Falcao2013-10-072-4/+66
|
* more refactoringGabriel Falcao2013-10-041-0/+34
|
* Starting to refactor the core moduleGabriel Falcao2013-10-042-0/+289
|
* temporarily solving #42 in a ugly way. Ready to refactor some codeGabriel Falcao2013-10-031-4/+2
|
* fixing the POST callback being called twice. closes #100, but might regress #42Gabriel Falcao2013-10-032-18/+35
|
* ignoring issue #100 in an unrelated functional test temporarilyGabriel Falcao2013-10-021-1/+3
|