mirror of
https://github.com/kennethreitz/requests.git
synced 2026-06-05 22:50:18 +00:00
Added autoauth tests
This commit is contained in:
+11
-10
@@ -1,17 +1,8 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
if sys.version_info >= (3,0):
|
||||
from io import StringIO
|
||||
else:
|
||||
try:
|
||||
from cStringIO import StringIO
|
||||
except ImportError:
|
||||
from StringIO import StringIO
|
||||
|
||||
import requests
|
||||
|
||||
|
||||
@@ -57,6 +48,16 @@ class RequestsTestSuite(unittest.TestCase):
|
||||
self.assertEqual(r.status_code, 200)
|
||||
|
||||
|
||||
requests.add_autoauth(url, auth)
|
||||
|
||||
r = requests.get(url)
|
||||
self.assertEqual(r.status_code, 200)
|
||||
|
||||
# reset auto authentication
|
||||
requests.AUTOAUTHS = []
|
||||
|
||||
|
||||
|
||||
def test_POSTBIN_GET_POST_FILES(self):
|
||||
|
||||
bin = requests.post('http://www.postbin.org/')
|
||||
@@ -65,7 +66,7 @@ class RequestsTestSuite(unittest.TestCase):
|
||||
post = requests.post(bin.url, data={'some': 'data'})
|
||||
self.assertEqual(post.status_code, 201)
|
||||
|
||||
post2 = requests.post(bin.url, files={'some': StringIO('data')})
|
||||
post2 = requests.post(bin.url, files={'some': open('test_requests.py')})
|
||||
self.assertEqual(post2.status_code, 201)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user