Skip to content

Commit 03bbcca

Browse files
authored
Merge pull request #594 from jdufresne/isinstance
Prefer assertIsInstance(...) over assertTrue(isinstance(...))
2 parents a49c773 + aef9a3e commit 03bbcca

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

tests/oauth1/rfc5849/test_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class ClientConstructorTests(TestCase):
3939
def test_convert_to_unicode_resource_owner(self):
4040
client = Client('client-key',
4141
resource_owner_key=b'owner key')
42-
self.assertFalse(isinstance(client.resource_owner_key, bytes_type))
42+
self.assertNotIsInstance(client.resource_owner_key, bytes_type)
4343
self.assertEqual(client.resource_owner_key, 'owner key')
4444

4545
def test_give_explicit_timestamp(self):

tests/openid/connect/core/grant_types/test_dispatchers.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,23 +36,23 @@ def test_create_authorization_response_openid(self):
3636
self.request.scopes = ('hello', 'openid')
3737
self.request.response_type = 'id_token'
3838
handler = self.dispatcher._handler_for_request(self.request)
39-
self.assertTrue(isinstance(handler, ImplicitGrant))
39+
self.assertIsInstance(handler, ImplicitGrant)
4040

4141
def test_validate_authorization_request_openid(self):
4242
self.request.scopes = ('hello', 'openid')
4343
self.request.response_type = 'id_token'
4444
handler = self.dispatcher._handler_for_request(self.request)
45-
self.assertTrue(isinstance(handler, ImplicitGrant))
45+
self.assertIsInstance(handler, ImplicitGrant)
4646

4747
def test_create_authorization_response_oauth(self):
4848
self.request.scopes = ('hello', 'world')
4949
handler = self.dispatcher._handler_for_request(self.request)
50-
self.assertTrue(isinstance(handler, ImplicitGrant))
50+
self.assertIsInstance(handler, ImplicitGrant)
5151

5252
def test_validate_authorization_request_oauth(self):
5353
self.request.scopes = ('hello', 'world')
5454
handler = self.dispatcher._handler_for_request(self.request)
55-
self.assertTrue(isinstance(handler, ImplicitGrant))
55+
self.assertIsInstance(handler, ImplicitGrant)
5656

5757

5858
class DispatcherTest(TestCase):
@@ -82,7 +82,7 @@ def setUp(self):
8282

8383
def test_create_token_response_openid(self):
8484
handler = self.dispatcher._handler_for_request(self.request)
85-
self.assertTrue(isinstance(handler, AuthorizationCodeGrant))
85+
self.assertIsInstance(handler, AuthorizationCodeGrant)
8686
self.assertTrue(self.dispatcher.request_validator.get_authorization_code_scopes.called)
8787

8888

@@ -104,7 +104,7 @@ def setUp(self):
104104

105105
def test_create_token_response_openid_without_code(self):
106106
handler = self.dispatcher._handler_for_request(self.request)
107-
self.assertTrue(isinstance(handler, OAuth2AuthorizationCodeGrant))
107+
self.assertIsInstance(handler, OAuth2AuthorizationCodeGrant)
108108
self.assertFalse(self.dispatcher.request_validator.get_authorization_code_scopes.called)
109109

110110

@@ -121,5 +121,5 @@ def setUp(self):
121121

122122
def test_create_token_response_oauth(self):
123123
handler = self.dispatcher._handler_for_request(self.request)
124-
self.assertTrue(isinstance(handler, OAuth2AuthorizationCodeGrant))
124+
self.assertIsInstance(handler, OAuth2AuthorizationCodeGrant)
125125
self.assertTrue(self.dispatcher.request_validator.get_authorization_code_scopes.called)

0 commit comments

Comments
 (0)