Commit Graph

145 Commits

Author SHA1 Message Date
kennethreitz 456be3cfde Merge pull request #3024 from Stranger6667/utils-unit-tests
Added unit tests for utils module
2016-04-06 15:05:13 -04:00
kennethreitz b6b1b3a81c Merge pull request #3049 from Stranger6667/test-hooks
Added unit tests for hooks module
2016-04-06 15:04:15 -04:00
kennethreitz 03ed671a41 Merge pull request #3059 from alexanderad/proxy-connection-errors
Raise a ProxyError for proxy related connection issues
2016-04-06 15:01:25 -04:00
Ben f24d56a1ce Consolidate logic for changing method during redirects
I only moved the code into a function, there was no actual change to
the code. I added a few tests to ensure we're doing things correctly.

The real point of me doing this is to make it easier to bring back
`strict_mode` functionality. For you requests youngsters in the crowd,
`strict_mode` followed the spec for redirects meaning the method
wouldn't change to a GET. The current code follows the browser
convention of changing the method to a GET when doing a 302 redirect.
However, lots of servers want you to follow the standards (the nerve!)
so I'd like to override the logic. Now that the method changing logic
is in `rebuild_method`, I can simply override that function instead of
overriding the entire `resolve_redirects` function as suggested by
kennethreitz/requests#1325
2016-03-17 23:16:39 -05:00
Alexander Shchapov 6ca9d71bb5 Raise a ProxyError for proxy related connection issues. 2016-03-17 15:46:26 -04:00
Dmitry Dygalo eddea4e914 Added unit tests for hooks module 2016-03-14 14:08:44 +01:00
Dmitry Dygalo 1eb153529a Merge remote-tracking branch 'upstream/master' into utils-unit-tests
Conflicts:
	tests/test_utils.py
2016-03-13 10:24:47 +01:00
Cory Benfield 6cc0b56d51 Switch to treat files without tell() as zero-length 2016-03-07 09:05:43 +00:00
Cory Benfield e034dd1140 Allow for exceptions from tell() 2016-03-07 08:31:23 +00:00
Casey Davidson f74a6707af Verify that cookie can be properly accessed if domain is specified, and that error is raised otherwise. Refs #3028. 2016-03-05 20:37:56 -08:00
Casey Davidson c53a685e7d Fix typo. 2016-03-05 20:30:36 -08:00
Casey Davidson b9517a58bc Assert that both cookies were added in test. Refs #3028. 2016-03-04 15:59:13 -08:00
Casey Davidson 1185d65202 Add tests to specify when CookieConflicError should be raised. References #3028. 2016-03-04 15:55:43 -08:00
Dmitry Dygalo f123f89d32 Added unit tests for utils module 2016-02-19 10:32:23 +01:00
kennethreitz bbadf47a8f syntax changes 2016-02-05 15:53:59 -05:00
Dmitry Dygalo 18b26d20f7 Added tests module. 2016-02-05 13:21:57 +01:00
Kenneth Reitz e4c4c80b82 remove all old tests 2012-12-17 07:27:25 -05:00
Kenneth Reitz 58c10edb07 Merge pull request #1006 from passy/test-py3k-fix
Use range in favor of xrange for py3k test compatibility
2012-12-15 02:22:25 -08:00
Kenneth Reitz 4a9f3572a3 logging handlers
Closes #971
2012-12-14 23:51:53 -05:00
Kenneth Reitz 79992579c9 remove danger_mode tests 2012-12-14 23:27:38 -05:00
Kenneth Reitz 67c7e496f5 remove safe_mode tests 2012-12-14 23:26:48 -05:00
Pascal Hartig a98ec717f2 Use range in favor of xrange for py3k compatibility
request_count is 2 so it really makes no difference performance-wise at all.
2012-12-14 23:29:33 +01:00
László Vaskó e8d20926d3 Added testcases for keep-alive handling
* Added a dummy_server module to check connection count
* Added testcases for proxy and direct connections
2012-12-02 01:06:52 +01:00
Kenneth Reitz d36ceb9d06 Merge pull request #953 from heyman/fix_session_safe_mode
Fixes so that safe_mode works for Sessions
2012-11-26 00:31:45 -08:00
Cory Benfield d5f9a2a51c Avoid using callable().
Callable() is not included in Python 3.1, so we shouldn't use it.
2012-11-24 12:15:30 +00:00
Jonatan Heyman 8269ee7266 Fixed so that safe_mode works for Sessions 2012-11-23 16:48:51 +01:00
Cory Benfield c02520ed99 Make sure we reset environment variables.
Turns out nose runs all the tests in one process, so changing the
os.environ dictionary makes everything go horribly wrong.
2012-11-18 12:31:55 +00:00
Cory Benfield 8da100f652 Respect the no_proxy environment variable.
This change is in response to issue #879.
2012-11-18 12:06:33 +00:00
Russell Davis ccf4ca8929 Fix a bug in _encode_params - it wasn't utf-8 encoding strings in values that
are iterable but not a list.
2012-11-03 12:58:04 -07:00
Martijn Pieters e26ccb34eb Fix the smoke test in the face of UTF-16 surrogate pairs.
If the random data starts with a UTF-16 BOM *and* the next two bytes are for a character in the `\ud800`-`\udfff` range decoding would fail. Small chance, but still possible.

Extend it to check the UTF-8 error as well. The goal is to test that the guesser was *mostly* correct, and to verify the cases where it wasn't that it was to be expected. Most of all that the function doesn't buckle under wildly unexpected data.
2012-10-26 12:15:27 +02:00
Martijn Pieters be01a35ef1 Better not call it chr, rename to byteschr. 2012-10-25 18:27:21 +02:00
Martijn Pieters a4be9a2578 Redefine the unichr and bytes-variant of chr at module level.
Needed to appease Travis; it's python 2.6 and 2.7 builds are weird and the `__builtins__` dict is not following CPython conventions.
2012-10-25 18:22:07 +02:00
Martijn Pieters 9832bd8917 Correct a c&p mistake: set a correct docstring for the unit test class. 2012-10-25 17:56:19 +02:00
Martijn Pieters 4decc7986e Use a JSON-specific encoding detection when no encoding has been specified.
JSON *must* be encoded using UTF-8, UTF-16 or UTF-32 (see the [RFC][1]; detect the encoding based on the fact that JSON always starts with 2 ASCII characters.

[1]: http://tools.ietf.org/html/rfc4627#section-3
2012-10-25 17:43:52 +02:00
Radu Voicilas ce7c86cc58 Replace assert statements with unittest's self.assert*
-- the incetive for this being that with self.assertEqual you get an
error message if the test fails
2012-10-18 22:24:59 +03:00
Kenneth Reitz aa08f33f98 Merge pull request #884 from everbird/develop
Support CJK parameters when post files
2012-10-17 07:21:39 -07:00
Stephen Zhuang bb9e72885a For the uniformity :) 2012-10-09 23:19:42 +08:00
Radu Voicilas 820dfb0495 Making the code more PEP8 compliant 2012-10-09 00:42:49 +03:00
Ian Cordasco 4e6cf21d82 Only register callable items in lists
Prior to this, you could sneak a list of anything to register_hook and it
would accept it. This will check if the items in the list are callable before
registering them. Also added a regression test to make sure if this gets
changed it will be noticed.
2012-10-09 00:42:49 +03:00
Stephen Zhuang 86b39bf3e3 Support CJK parameters when post files 2012-10-08 16:52:06 +08:00
Ian Cordasco 77677eb71d Only register callable items in lists
Prior to this, you could sneak a list of anything to register_hook and it
would accept it. This will check if the items in the list are callable before
registering them. Also added a regression test to make sure if this gets
changed it will be noticed.
2012-10-01 14:05:27 -04:00
Ian Cordasco 4dd3d1a1a2 Fix #785 & add regression test. 2012-09-20 11:45:03 -04:00
Eric Hansen 2dc7db4730 Fixed issue with empty proxies being passed 2012-09-11 15:40:16 -04:00
Shivaram Lingamneni c73646da00 fix some tests to correctly cover the API
After #831, the tests added in #764 (which relied on iter_content()
crashing if the response was prefetched) no longer tested what they
were intended to test.
2012-09-06 16:31:01 -07:00
Shivaram Lingamneni 77cf995165 permissive implementation of iter_content
This allows iter_content and iter_lines to succeed without
crashing even after the response content has been fetched
(iter_content gives you an iterator over the prefetched
content)
2012-09-02 01:42:30 -07:00
Kenneth Reitz 088454b145 Merge pull request #805 from Lukasa/develop
Remove None values from post data.
2012-08-25 07:35:06 -07:00
Rhys Elsmore 217a9d50cd Removed Duplicate Import 2012-08-23 16:18:47 +10:00
Cory Benfield b781acc7ab Add a failing test for Issue #378. 2012-08-22 22:33:20 +01:00
Kenneth Reitz 385217e55c Merge pull request #789 from zigmonty/http_digest_fixes
HTTPDigestAuth fixes
2012-08-18 17:42:40 -07:00
Kenneth Reitz 95493917f2 Merge pull request #791 from sigmavirus24/key_val_lists
Key val lists
2012-08-18 15:54:49 -07:00