Skip to content
Myr

Some pyflakes fixes.

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

They were just bothering me far too much with vim+syntastic.

authored by Ian Cordasco · committed by Ian Cordasco · parent 2b33bc2 · Browse files · 2 files+25 added−12 removed
This commit

State

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

Diff stats

2 files+25 added−12 removed

  • tests:+24 added−11 removed
  • other:+1 added−1 removed

2 files+25 added−12 removed

modified:tests/test_requests.py+24 added-11 removed
50 unmodified lines
51 # c = envoy.connect('httpbin %s' % (PORT))52 # time.sleep(1)53 _httpbin = True545556class TestBaseMixin(object):5758 def assertCookieHas(self, cookie, **kwargs):59 """Assert that a cookie has various specified properties."""60 for attr, expected_value in kwargs.items():61 cookie_attr = getattr(cookie, attr)61 message = 'Failed comparison for %s: %s != %s' % (attr, cookie_attr, expected_value)62 message = 'Failed comparison for %s: %s != %s' % (attr,63 cookie_attr, expected_value)64 self.assertEqual(cookie_attr, expected_value, message)656667class RequestsTestSuite(TestSetup, TestBaseMixin, unittest.TestCase):68 """Requests test cases."""6970 def test_entry_points(self):
52 unmodified lines
123124 def test_HTTP_200_OK_GET_WITH_MIXED_PARAMS(self):125 heads = {'User-agent': 'Mozilla/5.0'}126124 r = get(httpbin('get') + '?test=true', params={'q': 'test'}, headers=heads)127 r = get(httpbin('get') + '?test=true', params={'q': 'test'},128 headers=heads)129 self.assertEqual(r.status_code, 200)130131 # def test_unicode_headers(self):132 # # Simply calling requests with a unicode instance should simply work
631 unmodified lines
764 c = json.loads(r.text).get('cookies')765 self.assertEqual(c, _c)766767 # Have the server set a cookie.764 r = get(httpbin('cookies', 'set', 'k', 'v'), allow_redirects=True, session=s)768 r = get(httpbin('cookies', 'set', 'k', 'v'), allow_redirects=True,769 session=s)770 c = json.loads(r.text).get('cookies')771772 assert 'k' in c773
56 unmodified lines
830 self.assertCookieHas(cookie, name='a-cookie', value='cookie-value')831832 def test_unpickled_session_requests(self):833 s = requests.session()829 r = get(httpbin('cookies', 'set', 'k', 'v'), allow_redirects=True, session=s)834 r = get(httpbin('cookies', 'set', 'k', 'v'), allow_redirects=True,835 session=s)836 c = json.loads(r.text).get('cookies')837 assert 'k' in c838839 ds = pickle.loads(pickle.dumps(s))
120 unmodified lines
960 s = requests.session()961 s.config['danger_mode'] = True962 s.get(httpbin('redirect', '4'))963958964 def test_empty_response(self):965 r = requests.get(httpbin('status', '404'))966 r.text967968 def test_max_redirects(self):964 """Test the max_redirects config variable, normally and under safe_mode."""969 """Test the max_redirects config variable, normally and under970 safe_mode.971 """972 def unsafe_callable():966 requests.get(httpbin('redirect', '3'), config=dict(max_redirects=2))967 self.assertRaises(requests.exceptions.TooManyRedirects, unsafe_callable)973 requests.get(httpbin('redirect', '3'),974 config=dict(max_redirects=2))975 self.assertRaises(requests.exceptions.TooManyRedirects,976 unsafe_callable)977978 # add safe mode970 response = requests.get(httpbin('redirect', '3'), config=dict(safe_mode=True, max_redirects=2))979 response = requests.get(httpbin('redirect', '3'),980 config=dict(safe_mode=True, max_redirects=2))981 self.assertTrue(response.content is None)972 self.assertTrue(isinstance(response.error, requests.exceptions.TooManyRedirects))982 self.assertTrue(isinstance(response.error,983 requests.exceptions.TooManyRedirects))984985 def test_connection_keepalive_and_close(self):975 """Test that we send 'Connection: close' when keep_alive is disabled."""986 """Test that we send 'Connection: close' when keep_alive is987 disabled.988 """989 # keep-alive should be on by default990 r1 = requests.get(httpbin('get'))991 # XXX due to proxying issues, test the header sent back by httpbin, rather than992 # the header reported in its message body. See kennethreitz/httpbin#46
31 unmodified lines
modified:Makefile+1 added-1 removed
35 unmodified lines
36cipyflakes:37 ${PYFLAKES_IF_AVAILABLE} ${PYFLAKES_WHITELIST}3839citests:40 nosetests ${CI_TESTS} --with-xunit --xunit-file=junit-report.xml40 nosetests ${CI_TESTS} -v --with-xunit --xunit-file=junit-report.xml4142ci: citests cipyflakes4344travis: citests
36 unmodified lines