mirror of
https://github.com/kennethreitz/requests.git
synced 2026-06-05 22:50:18 +00:00
digestauth: threadsafe test
Signed-off-by: Pierre Tardy <pierre.tardy@intel.com>
This commit is contained in:
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user