Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,16 @@ def test_auth_code_flow(self):
self.assertLoosely(result, lambda: self.assertIn('access_token', result))

def test_auth_code_flow_error_response(self):
with self.assertRaisesRegexp(ValueError, "state missing"):
if hasattr(self, "assertRaisesRegex"):
_assert = self.assertRaisesRegex
else:
_assert = self.assertRaisesRegexp

with _assert(ValueError, "state missing"):
self.client.obtain_token_by_auth_code_flow({}, {"code": "foo"})
with self.assertRaisesRegexp(ValueError, "state mismatch"):
with _assert(ValueError, "state mismatch"):
self.client.obtain_token_by_auth_code_flow({"state": "1"}, {"state": "2"})
with self.assertRaisesRegexp(ValueError, "scope"):
with _assert(ValueError, "scope"):
self.client.obtain_token_by_auth_code_flow(
{"state": "s", "scope": ["foo"]}, {"state": "s"}, scope=["bar"])
self.assertEqual(
Expand Down