Skip to content
Myr

test for gzip decompress

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 7a62b10 · Browse files · 1 file+13 added−10 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+13 added−10 removed

  • other:+13 added−10 removed

1 file+13 added−10 removed

modified:test_requests.py+13 added-10 removed
28 unmodified lines
29 self.assertEqual(r.status_code, 200)3031 def test_HTTP_200_OK_GET_WITH_PARAMS(self):32 heads = {'User-agent': 'Mozilla/5.0'}33 3334 r = requests.get('http://www.google.com/search', params={'q': 'test'}, headers=heads)35 self.assertEqual(r.status_code, 200)3637 def test_HTTP_200_OK_GET_WITH_MIXED_PARAMS(self):
8 unmodified lines
46 'Mozilla/5.0 (github.com/kennethreitz/requests)'}4748 r = requests.get('http://whatsmyua.com', headers=heads);49 self.assertTrue(heads['User-agent'] in r.content)50 5051 def test_HTTP_200_OK_HEAD(self):52 r = requests.head('http://google.com')53 self.assertEqual(r.status_code, 200)54
17 unmodified lines
72 def test_POSTBIN_GET_POST_FILES(self):73 bin = requests.post('http://www.postbin.org/')74 print bin.url75 self.assertEqual(bin.status_code, 200)76 7677 post = requests.post(bin.url, data={'some': 'data'})78 self.assertEqual(post.status_code, 201)7980 post2 = requests.post(bin.url, files={'some': open('test_requests.py')})81 self.assertEqual(post2.status_code, 201)8283 def test_POSTBIN_GET_POST_FILES_WITH_PARAMS(self):84 bin = requests.post('http://www.postbin.org/')85 8586 self.assertEqual(bin.status_code, 200)8788 post2 = requests.post(bin.url, files={'some': open('test_requests.py')}, data={'some': 'data'})89 self.assertEqual(post2.status_code, 201)
6 unmodified lines
96 post2 = requests.post(bin.url, files={'some': open('test_requests.py')},97 headers={'User-Agent': 'requests-tests'})9899 self.assertEqual(post2.status_code, 201)100 100101 def test_nonzero_evaluation(self):102 r = requests.get('http://google.com/some-404-url')103 self.assertEqual(bool(r), False)104 104105 r = requests.get('http://google.com/')106 self.assertEqual(bool(r), True)107 107108 def test_request_ok_set(self):109 r = requests.get('http://google.com/some-404-url')110 self.assertEqual(r.ok, False)111 111112 def test_status_raising(self):113 r = requests.get('http://google.com/some-404-url')114 self.assertRaises(requests.HTTPError, r.raise_for_status)115 115116 r = requests.get('http://google.com/')117 self.assertFalse(r.error)118 r.raise_for_status()119 119120 def test_cookie_jar(self):121 """122 .. todo:: This really doesn't test to make sure the cookie is working123 """
2 unmodified lines
126127 requests.get('http://google.com', cookies=jar)128 self.assertTrue(jar)129130 def test_decompress_gzip(self):131132 r = requests.get('http://api.stackoverflow.com/1.1/users/495995/top-answer-tags')133 r.content.decode('ascii')134135if __name__ == '__main__':136 unittest.main()