Skip to content
Myr

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

1 file+12 added−22 removed

modified:test_requests.py+12 added-22 removed
15 unmodified lines
16from requests.adapters import HTTPAdapter17from requests.auth import HTTPDigestAuth, _basic_auth_str18from requests.compat import (19 Morsel, cookielib, getproxies, str, urljoin, urlparse, is_py3,20 builtin_str, OrderedDict21 )20 builtin_str, OrderedDict)21from requests.cookies import cookiejar_from_dict, morsel_to_cookie23from requests.exceptions import (ConnectionError, ConnectTimeout,24 InvalidSchema, InvalidURL, MissingSchema,25 ReadTimeout, Timeout, RetryError, TooManyRedirects)22from requests.exceptions import (23 ConnectionError, ConnectTimeout, InvalidSchema, InvalidURL,24 MissingSchema, ReadTimeout, Timeout, RetryError, TooManyRedirects)25from requests.models import PreparedRequest26from requests.structures import CaseInsensitiveDict27from requests.sessions import SessionRedirectMixin28from requests.models import urlencode
56 unmodified lines
85 requests.put86 requests.patch87 requests.post8890 @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 lines
125 request = requests.Request('GET', "http://0.0.0.0/get/test case").prepare()126127 assert request.path_url == '/get/test%20case'128131 @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 lines
295 req_urls = [r.request.url for r in resp.history]296 assert urls == req_urls297298 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 lines
343 s.auth = auth344 r = s.get(url)345 assert r.status_code == 200346352 @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 ConnectionError
825 unmodified lines
117711781179class TestCaseInsensitiveDict:11801187 @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 lines
1459 assert quoted == requote_uri(quoted)146014611462class TestMorselToCookieExpires:14701463 """Tests for morsel_to_cookie when morsel contains expires."""14641465 def test_expires_valid_str(self):1466 """Test case where we convert expires from string time."""
2 unmodified lines
1469 morsel['expires'] = 'Thu, 01-Jan-1970 00:00:01 GMT'1470 cookie = morsel_to_cookie(morsel)1471 assert cookie.expires == 114721481 @pytest.mark.parametrize(1482 'value, exception',1473 @pytest.mark.parametrize('value, exception',1474 (1475 (100, TypeError),1476 ('woops', ValueError),1477 )
155 unmodified lines
1633 return [1634 (('a', 'b'), ('c', 'd')),1635 (('c', 'd'), ('a', 'b')),1636 (('a', 'b'), ('c', 'd'), ('e', 'f')),1646 ]1637 ]163816391640def 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