Skip to content

Commit 5aa60bf

Browse files
jdufresnesingingwolfboy
authored andcommitted
Remove testing workarounds for Python 2.6 (#353)
Python 2.6 has not been supported since 84ad78c in the v1.0.0 release.
1 parent 364762e commit 5aa60bf

File tree

2 files changed

+5
-25
lines changed

2 files changed

+5
-25
lines changed

tests/test_oauth1_session.py

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,6 @@
6262

6363

6464
class OAuth1SessionTest(unittest.TestCase):
65-
66-
def setUp(self):
67-
# For python 2.6
68-
if not hasattr(self, 'assertIn'):
69-
self.assertIn = lambda a, b: self.assertTrue(a in b)
70-
7165
def test_signature_types(self):
7266
def verify_signature(getter):
7367
def fake_send(r, **kwargs):
@@ -204,14 +198,9 @@ def _test_fetch_access_token_raises_error(self, auth):
204198
passed in to the client.
205199
"""
206200
auth.send = self.fake_body('oauth_token=foo')
207-
208-
# Use a try-except block so that we can assert on the exception message
209-
# being raised and also keep the Python2.6 compatibility where
210-
# assertRaises is not a context manager.
211-
try:
201+
with self.assertRaises(ValueError) as cm:
212202
auth.fetch_access_token('https://example.com/token')
213-
except ValueError as exc:
214-
self.assertEqual('No client verifier has been set.', str(exc))
203+
self.assertEqual('No client verifier has been set.', str(cm.exception))
215204

216205
def test_fetch_token_invalid_response(self):
217206
auth = OAuth1Session('foo')
@@ -221,15 +210,10 @@ def test_fetch_token_invalid_response(self):
221210

222211
for code in (400, 401, 403):
223212
auth.send = self.fake_body('valid=response', code)
224-
# use try/catch rather than self.assertRaises, so we can
225-
# assert on the properties of the exception
226-
try:
213+
with self.assertRaises(ValueError) as cm:
227214
auth.fetch_request_token('https://example.com/token')
228-
except ValueError as err:
229-
self.assertEqual(err.status_code, code)
230-
self.assertTrue(isinstance(err.response, requests.Response))
231-
else: # no exception raised
232-
self.fail("ValueError not raised")
215+
self.assertEqual(cm.exception.status_code, code)
216+
self.assertIsInstance(cm.exception.response, requests.Response)
233217

234218
def test_fetch_access_token_missing_verifier(self):
235219
self._test_fetch_access_token_raises_error(OAuth1Session('foo'))

tests/test_oauth2_session.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,6 @@ def fake_send(r, **kwargs):
2929
class OAuth2SessionTest(TestCase):
3030

3131
def setUp(self):
32-
# For python 2.6
33-
if not hasattr(self, 'assertIn'):
34-
self.assertIn = lambda a, b: self.assertTrue(a in b)
35-
3632
self.token = {
3733
'token_type': 'Bearer',
3834
'access_token': 'asdfoiw37850234lkjsdfsdf',

0 commit comments

Comments
 (0)