diff options
author | Danny Hermes <daniel.j.hermes@gmail.com> | 2015-12-14 13:31:22 -0800 |
---|---|---|
committer | Danny Hermes <daniel.j.hermes@gmail.com> | 2015-12-14 13:31:22 -0800 |
commit | f3a118a5d381cf57e0680285103aaf5a3465aa85 (patch) | |
tree | 901abc2ecc86187313e000c2b053eb3b29765617 /tests/test_service_account.py | |
parent | 7559dcb019eaff3a436debed047dd2aee06ab7de (diff) | |
download | oauth2client-f3a118a5d381cf57e0680285103aaf5a3465aa85.tar.gz |
Improved unit-test line coverage and quality.
In particular
- Upgraded some unit test modules to `unittest2`.
- Got to 100% line coverage in `test_jwt`, `test_clientsecrets`,
and `test_service_account` by using `self.assertRaises`
instead of `self.fail()`
- In some places used `self.assertRaises` as a context manager so
the thrown exception can be inspected / compared against. This
is done instead of manually catching the exception and
holding on to it (`unittest2` backports this feature from
`unittest` that was not available in Python 2.6)
- Added license to `test_multistore_file`
- Removed legacy `python2.4` hashbang from `test_jwt` and
`test_service_account`
- Added `unittest2` as a test dependency in `tox.ini`
- Updated `test_clientsecrets.test_load_by_filename_missing_file`
to use the `self.assertRaises` context manager (this was
a problem in #349 and #350)
- Updated `test_jwt` module docstring to reflect actual purpose
Diffstat (limited to 'tests/test_service_account.py')
-rw-r--r-- | tests/test_service_account.py | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/tests/test_service_account.py b/tests/test_service_account.py index 5cf1c1c..1ba0cae 100644 --- a/tests/test_service_account.py +++ b/tests/test_service_account.py @@ -1,5 +1,3 @@ -#!/usr/bin/python2.4 -# # Copyright 2014 Google Inc. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -61,17 +59,11 @@ class ServiceAccountCredentialsTests(unittest.TestCase): self.assertTrue(rsa.pkcs1.verify(b'Google', signature, pub_key)) - try: - rsa.pkcs1.verify(b'Orest', signature, pub_key) - self.fail('Verification should have failed!') - except rsa.pkcs1.VerificationError: - pass # Expected - - try: - rsa.pkcs1.verify(b'Google', b'bad signature', pub_key) - self.fail('Verification should have failed!') - except rsa.pkcs1.VerificationError: - pass # Expected + self.assertRaises(rsa.pkcs1.VerificationError, + rsa.pkcs1.verify, b'Orest', signature, pub_key) + self.assertRaises(rsa.pkcs1.VerificationError, + rsa.pkcs1.verify, + b'Google', b'bad signature', pub_key) def test_service_account_email(self): self.assertEqual(self.service_account_email, |