Skip to content
Myr

test for #458

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

authored by Shivaram Lingamneni · committed by Shivaram Lingamneni · parent 317f64a · Browse files · 1 file+16 added−2 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+16 added−2 removed

  • tests:+16 added−2 removed

1 file+16 added−2 removed

modified:tests/test_requests.py+16 added-2 removed
846 unmodified lines
847 r = requests.get(httpbin('status', '404'))848 r.text849850 def test_max_redirects(self):851 """Test the max_redirects config variable, normally and under safe_mode."""852 def unsafe_callable():852 requests.get("http://httpbin.org/redirect/3", config=dict(max_redirects=2))853 requests.get(httpbin('redirect', '3'), config=dict(max_redirects=2))854 self.assertRaises(requests.exceptions.TooManyRedirects, unsafe_callable)855856 # add safe mode856 response = requests.get("http://httpbin.org/redirect/3", config=dict(safe_mode=True, max_redirects=2))857 response = requests.get(httpbin('redirect', '3'), config=dict(safe_mode=True, max_redirects=2))858 self.assertTrue(response.content is None)859 self.assertTrue(isinstance(response.error, requests.exceptions.TooManyRedirects))860861 def test_connection_keepalive_and_close(self):862 """Test that we send 'Connection: close' when keep_alive is disabled."""863 # keep-alive should be on by default864 r1 = requests.get(httpbin('get'))865 # XXX due to proxying issues, test the header sent back by httpbin, rather than866 # the header reported in its message body. See kennethreitz/httpbin#46867 self.assertEqual(r1.headers['Connection'].lower(), 'keep-alive')868869 # but when we disable it, we should send a 'Connection: close'870 # and get the same back:871 r2 = requests.get(httpbin('get'), config=dict(keep_alive=False))872 self.assertEqual(r2.headers['Connection'].lower(), 'close')873874if __name__ == '__main__':875 unittest.main()