digestauth: threadsafe test

Signed-off-by: Pierre Tardy <pierre.tardy@intel.com>
This commit is contained in:
Pierre Tardy
2015-04-03 15:38:59 +02:00
committed by exvito
parent e8d9bc55bc
commit 142e24de7b
+20
View File
@@ -32,6 +32,11 @@ try:
except ImportError:
import io as StringIO
try:
from multiprocessing.pool import ThreadPool
except ImportError:
ThreadPool = None
if is_py3:
def u(s):
return s
@@ -411,6 +416,21 @@ class RequestsTestCase(unittest.TestCase):
r = requests.get(url, auth=auth)
assert '"auth"' in r.request.headers['Authorization']
def test_DIGESTAUTH_THREADED(self):
auth = HTTPDigestAuth('user', 'pass')
url = httpbin('digest-auth', 'auth', 'user', 'pass')
session = requests.Session()
session.auth=auth
def do_request(i):
r = session.get(url)
assert '"auth"' in r.request.headers['Authorization']
return 1
if ThreadPool is not None:
pool = ThreadPool(processes=50)
pool.map(do_request, range(100))
def test_POSTBIN_GET_POST_FILES(self):
url = httpbin('post')