Skip to content
This repository has been archived by the owner on Jan 18, 2025. It is now read-only.

Commit

Permalink
Remove unneeded clauses
Browse files Browse the repository at this point in the history
Don't need the `if __name__ == '__main__':` clauses in the test files.
  • Loading branch information
pferate committed Jul 6, 2016
1 parent b1d3285 commit 06e7032
Show file tree
Hide file tree
Showing 22 changed files with 2 additions and 88 deletions.
4 changes: 0 additions & 4 deletions tests/contrib/test__appengine_ndb.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,3 @@ def test__from_base_type_bad_json(self):
creds_prop = TestNDBModel.creds
creds_json = '{JK-I-AM-NOT-JSON'
self.assertIsNone(creds_prop._from_base_type(creds_json))


if __name__ == '__main__': # pragma: NO COVER
unittest2.main()
4 changes: 0 additions & 4 deletions tests/contrib/test_appengine.py
Original file line number Diff line number Diff line change
Expand Up @@ -1081,7 +1081,3 @@ def test_build_and_parse_state(self):
appengine._parse_state_value(state, UserMock()))
with self.assertRaises(appengine.InvalidXsrfTokenError):
appengine._parse_state_value(state[1:], UserMock())


if __name__ == '__main__': # pragma: NO COVER
unittest2.main()
4 changes: 0 additions & 4 deletions tests/contrib/test_devshell.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,3 @@ def test_serialization_data(self):
credentials = DevshellCredentials()
with self.assertRaises(NotImplementedError):
getattr(credentials, 'serialization_data')


if __name__ == '__main__': # pragma: NO COVER
unittest2.main()
4 changes: 0 additions & 4 deletions tests/contrib/test_dictionary_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,3 @@ def test_delete(self):

self.assertNotIn(key, dictionary)
self.assertIsNone(storage.get())


if __name__ == '__main__': # pragma: NO COVER
unittest2.main()
4 changes: 0 additions & 4 deletions tests/contrib/test_django_orm.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,3 @@ def __init__(self, set_store=False, *args, **kwargs):
self.deleted = False

credentials = CredentialsField()


if __name__ == '__main__': # pragma: NO COVER
unittest2.main()
4 changes: 0 additions & 4 deletions tests/contrib/test_flask_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,3 @@ def test_delete(self):
self.oauth2.storage.delete()

self.assertNotIn('google_oauth2_credentials', flask.session)


if __name__ == '__main__': # pragma: NO COVER
unittest2.main()
4 changes: 0 additions & 4 deletions tests/contrib/test_gce.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,3 @@ def test_save_to_well_known_file(self):
save_to_well_known_file(credentials)
finally:
os.path.isdir = ORIGINAL_ISDIR


if __name__ == '__main__': # pragma: NO COVER
unittest2.main()
4 changes: 0 additions & 4 deletions tests/contrib/test_keyring_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,3 @@ def acquire(self):

def release(self):
self._release_count += 1


if __name__ == '__main__': # pragma: NO COVER
unittest2.main()
4 changes: 0 additions & 4 deletions tests/contrib/test_locked_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,3 @@ def test_unlock_and_close(self):
instance, opener = self._make_one()
instance.unlock_and_close()
opener.unlock_and_close.assert_called_with()


if __name__ == '__main__': # pragma: NO COVER
unittest2.main()
4 changes: 0 additions & 4 deletions tests/contrib/test_multistore_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,3 @@ def test__delete_credential_nonexistent(self):
multistore._data = {}
multistore._delete_credential('nonexistent_key')
self.assertTrue(write_mock.called)


if __name__ == '__main__': # pragma: NO COVER
unittest2.main()
4 changes: 0 additions & 4 deletions tests/contrib/test_xsrfutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,3 @@ def testGenerateAndValidateToken(self):
None,
TEST_USER_ID_1,
action_id=TEST_ACTION_ID_1))


if __name__ == '__main__': # pragma: NO COVER
unittest2.main()
4 changes: 0 additions & 4 deletions tests/test__helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,3 @@ def test_bad_input(self):
bad_string = b'+'
with self.assertRaises((TypeError, binascii.Error)):
_urlsafe_b64decode(bad_string)


if __name__ == '__main__': # pragma: NO COVER
unittest2.main()
4 changes: 0 additions & 4 deletions tests/test__pure_python_crypt.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,3 @@ def test_from_string_bogus_key(self):
key_bytes = 'bogus-key'
with self.assertRaises(ValueError):
RsaSigner.from_string(key_bytes)


if __name__ == '__main__': # pragma: NO COVER
unittest2.main()
4 changes: 0 additions & 4 deletions tests/test__pycrypto_crypt.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,3 @@ def test_from_string_bad_key(self):
key_bytes = 'definitely-not-pem-format'
with self.assertRaises(NotImplementedError):
PyCryptoSigner.from_string(key_bytes)


if __name__ == '__main__': # pragma: NO COVER
unittest2.main()
4 changes: 0 additions & 4 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2377,7 +2377,3 @@ def test_FromResponse_with_expires_in(self, utcnow):
expected_result = DeviceFlowInfo(self.DEVICE_CODE, self.USER_CODE,
None, self.VER_URL, expire)
self.assertEqual(result, expected_result)


if __name__ == '__main__': # pragma: NO COVER
unittest2.main()
4 changes: 0 additions & 4 deletions tests/test_clientsecrets.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,3 @@ def test_without_cache(self):
client_type, client_info = clientsecrets.loadfile(VALID_FILE)
self.assertEqual('web', client_type)
self.assertEqual('foo_client_secret', client_info['client_secret'])


if __name__ == '__main__': # pragma: NO COVER
unittest2.main()
4 changes: 0 additions & 4 deletions tests/test_crypt.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,3 @@ def test_success(self, verify_sig, verify_time, check_aud):
verify_time.assert_called_once_with(payload_dict)
check_aud.assert_called_once_with(payload_dict, audience)
certs.values.assert_called_once_with()


if __name__ == '__main__': # pragma: NO COVER
unittest2.main()
4 changes: 0 additions & 4 deletions tests/test_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,3 @@ def test_access_token_credentials(self):
if os.name == 'posix': # pragma: NO COVER
mode = os.stat(FILENAME).st_mode
self.assertEquals('0o600', oct(stat.S_IMODE(mode)))


if __name__ == '__main__': # pragma: NO COVER
unittest2.main()
4 changes: 0 additions & 4 deletions tests/test_jwt.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,3 @@ class TestHasOpenSSLFlag(unittest2.TestCase):
def test_true(self):
self.assertEqual(True, HAS_OPENSSL)
self.assertEqual(True, HAS_CRYPTO)


if __name__ == '__main__': # pragma: NO COVER
unittest2.main()
3 changes: 0 additions & 3 deletions tests/test_service_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,3 @@ def test_refresh(self, utcnow):
token_2 = self.jwt.access_token
self.assertEquals(self.jwt.token_expiry, T2_EXPIRY_DATE)
self.assertNotEqual(token_1, token_2)

if __name__ == '__main__': # pragma: NO COVER
unittest2.main()
8 changes: 2 additions & 6 deletions tests/test_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def test_run_flow_no_webserver_explicit_flags(
self.assertEqual(self.flow.redirect_uri, OOB_CALLBACK_URN)
self.flow.step2_exchange.assert_called_once_with(
'auth_code', http=None)

@mock.patch('oauth2client.tools.logging')
@mock.patch('oauth2client.tools.input')
def test_run_flow_no_webserver_exchange_error(
Expand Down Expand Up @@ -161,7 +161,7 @@ def test_run_flow_webserver_no_code(
self, webbrowser_open_mock, server_ctor_mock, logging_mock):
server_ctor_mock.return_value = self.server
self.server.query_params = {}

# No code found in response
with self.assertRaises(SystemExit):
returned_credentials = tools.run_flow(
Expand Down Expand Up @@ -193,7 +193,3 @@ def test_run_flow_webserver_fallback(
class TestMessageIfMissing(unittest2.TestCase):
def test_message_if_missing(self):
self.assertIn('somefile.txt', tools.message_if_missing('somefile.txt'))


if __name__ == '__main__': # pragma: NO COVER
unittest.main()
3 changes: 0 additions & 3 deletions tests/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,3 @@ def test__add_query_parameter(self):
self.assertEqual(
util._add_query_parameter('/action', 'a', ' ='),
'/action?a=+%3D')

if __name__ == '__main__': # pragma: NO COVER
unittest2.main()

0 comments on commit 06e7032

Please sign in to comment.