minor PEP 8 fixes, compatibility with python 2.7
parent
606fd8f891
commit
55c7f4138a
10
test/test.py
10
test/test.py
|
@ -1,8 +1,8 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
from __future__ import absolute_import, division, print_function, unicode_literals
|
from __future__ import absolute_import, division, print_function
|
||||||
|
|
||||||
import os, sys, unittest, json, logging, base64
|
import os, sys, unittest, logging, base64
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
from requests.adapters import HTTPAdapter
|
from requests.adapters import HTTPAdapter
|
||||||
|
@ -13,8 +13,10 @@ from requests_http_signature import HTTPSignatureAuth, HTTPSignatureHeaderAuth,
|
||||||
hmac_secret = b"monorail_cat"
|
hmac_secret = b"monorail_cat"
|
||||||
passphrase = b"passw0rd"
|
passphrase = b"passw0rd"
|
||||||
|
|
||||||
|
|
||||||
class TestAdapter(HTTPAdapter):
|
class TestAdapter(HTTPAdapter):
|
||||||
def __init__(self, testcase):
|
def __init__(self, testcase):
|
||||||
|
super(TestAdapter, self).__init__()
|
||||||
self.testcase = testcase
|
self.testcase = testcase
|
||||||
|
|
||||||
def send(self, request, *args, **kwargs):
|
def send(self, request, *args, **kwargs):
|
||||||
|
@ -33,12 +35,16 @@ class TestAdapter(HTTPAdapter):
|
||||||
response.url = request.url
|
response.url = request.url
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
|
||||||
class DigestlessSignatureAuth(HTTPSignatureAuth):
|
class DigestlessSignatureAuth(HTTPSignatureAuth):
|
||||||
def add_digest(self, request):
|
def add_digest(self, request):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class TestRequestsHTTPSignature(unittest.TestCase):
|
class TestRequestsHTTPSignature(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
if not hasattr(unittest.TestCase, 'assertRaisesRegex'):
|
||||||
|
setattr(unittest.TestCase, 'assertRaisesRegex', unittest.TestCase.assertRaisesRegexp)
|
||||||
logging.basicConfig(level="DEBUG")
|
logging.basicConfig(level="DEBUG")
|
||||||
self.session = requests.Session()
|
self.session = requests.Session()
|
||||||
self.session.mount("http://", TestAdapter(self))
|
self.session.mount("http://", TestAdapter(self))
|
||||||
|
|
Loading…
Reference in New Issue