whitespace
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 e635690 · Browse files · 1 file·+21 added−0 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+21 added−0 removed
- other:+21 added−0 removed
Provenance
- Commit
cd0d0a2- Tree
fcf307d- Author
Kenneth Reitz <me@kennethreitz.com>- Committer
Kenneth Reitz <me@kennethreitz.com>- Parent
e635690
1 file changed+21 added−0 removed
modified:test_requests.py+21 added
13 unmodified lines14 15 def setUp(self):16 pass17 18+ 19 def tearDown(self):20 """Teardown."""21 pass22 23+ 24 def test_invalid_url(self):25 self.assertRaises(ValueError, requests.get, 'hiwpefhipowhefopw')26 27+ 28 def test_HTTP_200_OK_GET(self):29 r = requests.get('http://google.com')30 self.assertEqual(r.status_code, 200)31 32+ 33 def test_HTTPS_200_OK_GET(self):34 r = requests.get('https://google.com')35 self.assertEqual(r.status_code, 200)36 37+ 38 def test_HTTP_200_OK_GET_WITH_PARAMS(self):39 heads = {'User-agent': 'Mozilla/5.0'}40 41 r = requests.get('http://www.google.com/search', params={'q': 'test'}, headers=heads)42 self.assertEqual(r.status_code, 200)43 44+ 45 def test_HTTP_200_OK_GET_WITH_MIXED_PARAMS(self):46 heads = {'User-agent': 'Mozilla/5.0'}47 48 r = requests.get('http://google.com/search?test=true', params={'q': 'test'}, headers=heads)49 self.assertEqual(r.status_code, 200)50 51+ 52 def test_user_agent_transfers(self):53 """Issue XX"""54 heads = {55 'User-agent':10 unmodified lines66 67 r = requests.get('http://whatsmyua.com', headers=heads);68 self.assertTrue(heads['user-agent'] in r.content)69 70+ 71 def test_HTTP_200_OK_HEAD(self):72 r = requests.head('http://google.com')73 self.assertEqual(r.status_code, 200)74 75+ 76 def test_HTTPS_200_OK_HEAD(self):77 r = requests.head('https://google.com')78 self.assertEqual(r.status_code, 200)79 80+ 81 def test_AUTH_HTTPS_200_OK_GET(self):82 auth = ('requeststest', 'requeststest')83 url = 'https://convore.com/api/account/verify.json'84 r = requests.get(url, auth=auth)5 unmodified lines90 91 # reset auto authentication92 requests.auth_manager.empty()93 94+ 95 def test_POSTBIN_GET_POST_FILES(self):96 bin = requests.post('http://www.postbin.org/')97 self.assertEqual(bin.status_code, 302)98 36 unmodified lines135 136 r = requests.get('http://google.com/')137 self.assertEqual(bool(r), True)138 139+ 140 def test_request_ok_set(self):141 r = requests.get('http://google.com/some-404-url')142 self.assertEqual(r.ok, False)143 144+ 145 def test_status_raising(self):146 r = requests.get('http://google.com/some-404-url')147 self.assertRaises(requests.HTTPError, r.raise_for_status)148 149 r = requests.get('http://google.com/')150 self.assertFalse(r.error)151 r.raise_for_status()152 153+ 154 def test_cookie_jar(self):155 """156 .. todo:: This really doesn't test to make sure the cookie is working157 """3 unmodified lines161 162 requests.get('http://google.com', cookies=jar)163 self.assertTrue(jar)164 165+ 166 def test_decompress_gzip(self):167 168 r = requests.get('http://api.stackoverflow.com/1.1/users/495995/top-answer-tags')169 r.content.decode('ascii')170 171+ 172 def test_autoauth(self):173 174 conv_auth = ('requeststest', 'requeststest')175 requests.auth_manager.add_auth('convore.com', conv_auth)176 177 r = requests.get('https://convore.com/api/account/verify.json')178 self.assertEquals(r.status_code, 200)179 180+ 181 def test_unicode_get(self):182+ 183 requests.get('http://google.com', params={'foo': u'føø'})184 requests.get('http://google.com', params={u'føø': u'føø'})185 requests.get('http://google.com', params={'føø': 'føø'})186 requests.get('http://google.com', params={'foo': u'foo'})187 requests.get('http://google.com/ø', params={'foo': u'foo'})188 189+ 190 def test_httpauth_recursion(self):191 conv_auth = ('requeststest', 'bad_password')192 193 r = requests.get('https://convore.com/api/account/verify.json', auth=conv_auth)194 self.assertEquals(r.status_code, 401)195 196+ 197 def test_settings(self):198 with requests.settings(timeout=0.0001):199 self.assertRaises(requests.Timeout, requests.get, 'http://google.com')200 201 with requests.settings(timeout=10):202 requests.get('http://google.com')203 204+205 def test_nonurlencoded_post_data(self):206 requests.post('http://google.com', data='foo')207 208 3 unmodified lines