Skip to content
Myr

Revert "Some pyflakes fixes."

Before adoption: this commit came in with the history the project adopted, so no landing records it.

This reverts commit c71f48b5f1d989644e26b9004c2af7a6f27d4708. To please his BDFLness @kennethreitz ;)

authored by Ian Cordasco · committed by Ian Cordasco · parent 329af44 · Browse files · 1 file+11 added−24 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+11 added−24 removed

  • tests:+11 added−24 removed

1 file+11 added−24 removed

modified:tests/test_requests.py+11 added-24 removed
50 unmodified lines
51 # c = envoy.connect('httpbin %s' % (PORT))52 # time.sleep(1)53 _httpbin = True545555class TestBaseMixin(object):5657 def assertCookieHas(self, cookie, **kwargs):58 """Assert that a cookie has various specified properties."""59 for attr, expected_value in kwargs.items():60 cookie_attr = getattr(cookie, attr)62 message = 'Failed comparison for %s: %s != %s' % (attr,63 cookie_attr, expected_value)61 message = 'Failed comparison for %s: %s != %s' % (attr, cookie_attr, expected_value)62 self.assertEqual(cookie_attr, expected_value, message)636664class RequestsTestSuite(TestSetup, TestBaseMixin, unittest.TestCase):65 """Requests test cases."""6667 def test_entry_points(self):
57 unmodified lines
125126 def test_HTTP_200_OK_GET_WITH_MIXED_PARAMS(self):127 heads = {'User-agent': 'Mozilla/5.0'}128132 r = get(httpbin('get') + '?test=true', params={'q': 'test'},133 headers=heads)129 r = get(httpbin('get') + '?test=true', params={'q': 'test'}, headers=heads)130 self.assertEqual(r.status_code, 200)131132 # def test_unicode_headers(self):133 # # Simply calling requests with a unicode instance should simply work
636 unmodified lines
770 c = json.loads(r.text).get('cookies')771 self.assertEqual(c, _c)772773 # Have the server set a cookie.778 r = get(httpbin('cookies', 'set', 'k', 'v'), allow_redirects=True,779 session=s)774 r = get(httpbin('cookies', 'set', 'k', 'v'), allow_redirects=True, session=s)775 c = json.loads(r.text).get('cookies')776777 assert 'k' in c778
56 unmodified lines
835 self.assertCookieHas(cookie, name='a-cookie', value='cookie-value')836837 def test_unpickled_session_requests(self):838 s = requests.session()844 r = get(httpbin('cookies', 'set', 'k', 'v'), allow_redirects=True,845 session=s)839 r = get(httpbin('cookies', 'set', 'k', 'v'), allow_redirects=True, session=s)840 c = json.loads(r.text).get('cookies')841 assert 'k' in c842843 ds = pickle.loads(pickle.dumps(s))
133 unmodified lines
977 s = requests.session()978 s.config['danger_mode'] = True979 s.get(httpbin('redirect', '4'))980981982 def test_empty_response(self):983 r = requests.get(httpbin('status', '404'))984 r.text985986 def test_max_redirects(self):992 """Test the max_redirects config variable, normally and under993 safe_mode.994 """987 """Test the max_redirects config variable, normally and under safe_mode."""988 def unsafe_callable():996 requests.get(httpbin('redirect', '3'),997 config=dict(max_redirects=2))998 self.assertRaises(requests.exceptions.TooManyRedirects,999 unsafe_callable)989 requests.get(httpbin('redirect', '3'), config=dict(max_redirects=2))990 self.assertRaises(requests.exceptions.TooManyRedirects, unsafe_callable)991992 # add safe mode1002 response = requests.get(httpbin('redirect', '3'),1003 config=dict(safe_mode=True, max_redirects=2))993 response = requests.get(httpbin('redirect', '3'), config=dict(safe_mode=True, max_redirects=2))994 self.assertTrue(response.content is None)1005 self.assertTrue(isinstance(response.error,1006 requests.exceptions.TooManyRedirects))995 self.assertTrue(isinstance(response.error, requests.exceptions.TooManyRedirects))996997 def test_connection_keepalive_and_close(self):1009 """Test that we send 'Connection: close' when keep_alive is1010 disabled.1011 """998 """Test that we send 'Connection: close' when keep_alive is disabled."""999 # keep-alive should be on by default1000 r1 = requests.get(httpbin('get'))1001 # XXX due to proxying issues, test the header sent back by httpbin, rather than1002 # the header reported in its message body. See kennethreitz/httpbin#46
110 unmodified lines