Adding test to ensure options like stream function with authentication
authorMichael Komitee <mkomitee@gmail.com>
Thu, 14 Feb 2013 02:28:32 +0000 (21:28 -0500)
committerMichael Komitee <mkomitee@gmail.com>
Thu, 14 Feb 2013 02:28:32 +0000 (21:28 -0500)
This test demonstrates the reason why we need to pass kwargs to hooks. Without
it, features like stream cannot work with authentication.

test_requests.py

index e12722d1aeee93ced492d68e3ad8739b301fdaf8..f6f55319d99f8e47ca3c62dd75773ab2709d639b 100644 (file)
@@ -172,6 +172,18 @@ class RequestsTestCase(unittest.TestCase):
         r = s.get(url)
         self.assertEqual(r.status_code, 200)
 
+    def test_DIGEST_STREAM(self):
+
+        auth = HTTPDigestAuth('user', 'pass')
+        url = httpbin('digest-auth', 'auth', 'user', 'pass')
+
+        r = requests.get(url, auth=auth, stream=True)
+        self.assertNotEqual(r.raw.read(), '')
+
+        r = requests.get(url, auth=auth, stream=False)
+        self.assertEqual(r.raw.read(), '')
+
+
     def test_DIGESTAUTH_WRONG_HTTP_401_GET(self):
 
         auth = HTTPDigestAuth('user', 'wrongpass')