cleandup test_requests.py
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Kenneth Reitz · committed by Kenneth Reitz · parent 90688c6 · Browse files · 1 file·+12 added−22 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
1 file+12 added−22 removed
- other:+12 added−22 removed
Provenance
- Commit
6e35ec4- Tree
33dd850- Author
Kenneth Reitz <me@kennethreitz.org>- Committer
Kenneth Reitz <me@kennethreitz.org>- Parent
90688c6
1 file changed+12 added−22 removed
modified:test_requests.py+12 added-22 removed
15 unmodified lines16 from requests.adapters import HTTPAdapter17 from requests.auth import HTTPDigestAuth, _basic_auth_str18 from requests.compat import (19 Morsel, cookielib, getproxies, str, urljoin, urlparse, is_py3,20- builtin_str, OrderedDict21- )20+ builtin_str, OrderedDict)21 from requests.cookies import cookiejar_from_dict, morsel_to_cookie23-from requests.exceptions import (ConnectionError, ConnectTimeout,24- InvalidSchema, InvalidURL, MissingSchema,25- ReadTimeout, Timeout, RetryError, TooManyRedirects)22+from requests.exceptions import (23+ ConnectionError, ConnectTimeout, InvalidSchema, InvalidURL,24+ MissingSchema, ReadTimeout, Timeout, RetryError, TooManyRedirects)25 from requests.models import PreparedRequest26 from requests.structures import CaseInsensitiveDict27 from requests.sessions import SessionRedirectMixin28 from requests.models import urlencode56 unmodified lines85 requests.put86 requests.patch87 requests.post88 90- @pytest.mark.parametrize(91- 'exception, url',89+ @pytest.mark.parametrize('exception, url',90 (91 (MissingSchema, 'hiwpefhipowhefopw'),92 (InvalidSchema, 'localhost:3128'),93 (InvalidSchema, 'localhost.localdomain:3128/'),31 unmodified lines125 request = requests.Request('GET', "http://0.0.0.0/get/test case").prepare()126 127 assert request.path_url == '/get/test%20case'128 131- @pytest.mark.parametrize(132- 'url, expected',129+ @pytest.mark.parametrize('url, expected',130 (131 ('http://example.com/path#fragment', 'http://example.com/path?a=b#fragment'),132 ('http://example.com/path?key=value#fragment', 'http://example.com/path?key=value&a=b#fragment')133 )161 unmodified lines295 req_urls = [r.request.url for r in resp.history]296 assert urls == req_urls297 298 def test_history_is_always_a_list(self, httpbin):302- """303- Show that even with redirects, Response.history is always a list.304- """299+ """Show that even with redirects, Response.history is always a list."""300 resp = requests.get(httpbin('get'))301 assert isinstance(resp.history, list)302 resp = requests.get(httpbin('redirect/1'))303 assert isinstance(resp.history, list)39 unmodified lines343 s.auth = auth344 r = s.get(url)345 assert r.status_code == 200346 352- @pytest.mark.parametrize(353- 'url, exception',347+ @pytest.mark.parametrize('url, exception',348 (349 # Connecting to an unknown domain should raise a ConnectionError350 ('http://doesnotexist.google.com', ConnectionError),351 # Connecting to an invalid port should raise a ConnectionError825 unmodified lines1177 1178 1179 class TestCaseInsensitiveDict:1180 1187- @pytest.mark.parametrize(1188- 'cid',1181+ @pytest.mark.parametrize('cid',1182 (1183 CaseInsensitiveDict({'Foo': 'foo', 'BAr': 'bar'}),1184 CaseInsensitiveDict([('Foo', 'foo'), ('BAr', 'bar')]),1185 CaseInsensitiveDict(FOO='foo', BAr='bar'),273 unmodified lines1459 assert quoted == requote_uri(quoted)1460 1461 1462 class TestMorselToCookieExpires:1470-1463 """Tests for morsel_to_cookie when morsel contains expires."""1464 1465 def test_expires_valid_str(self):1466 """Test case where we convert expires from string time."""2 unmodified lines1469 morsel['expires'] = 'Thu, 01-Jan-1970 00:00:01 GMT'1470 cookie = morsel_to_cookie(morsel)1471 assert cookie.expires == 11472 1481- @pytest.mark.parametrize(1482- 'value, exception',1473+ @pytest.mark.parametrize('value, exception',1474 (1475 (100, TypeError),1476 ('woops', ValueError),1477 )155 unmodified lines1633 return [1634 (('a', 'b'), ('c', 'd')),1635 (('c', 'd'), ('a', 'b')),1636 (('a', 'b'), ('c', 'd'), ('e', 'f')),1646- ]1637+ ]1638 1639 1640 def test_data_argument_accepts_tuples(list_of_tuples):1650- """1651- Ensure that the data argument will accept tuples of strings1641+ """Ensure that the data argument will accept tuples of strings1642 and properly encode them.1643 """1644 for data in list_of_tuples:1645 p = PreparedRequest()78 unmodified lines