diff options
author | Matěj Cepl <mcepl@cepl.eu> | 2015-10-19 20:48:04 +0200 |
---|---|---|
committer | Matěj Cepl <mcepl@cepl.eu> | 2015-10-27 18:46:40 +0100 |
commit | f45b71b10e0fc1580e32a9e98b7dceefa13f1cec (patch) | |
tree | 1c62388b23938eb9dde02ed8a409b5caedd678d3 /tests/test_bio.py | |
parent | 835a98cc13e5f451cc3a45446412063f110a676e (diff) | |
download | m2crypto-f45b71b10e0fc1580e32a9e98b7dceefa13f1cec.tar.gz |
Change self.assertRaises to context managers.
Diffstat (limited to 'tests/test_bio.py')
-rw-r--r-- | tests/test_bio.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/tests/test_bio.py b/tests/test_bio.py index 88b6902..ab727d5 100644 --- a/tests/test_bio.py +++ b/tests/test_bio.py @@ -41,9 +41,12 @@ class CipherStreamTestCase(unittest.TestCase): cf.close() assert not cf.readable() - self.assertRaises(IOError, cf.read) - self.assertRaises(IOError, cf.readline) - self.assertRaises(IOError, cf.readlines) + with self.assertRaises(IOError): + cf.read() + with self.assertRaises(IOError): + cf.readline() + with self.assertRaises(IOError): + cf.readlines() assert data == data2, '%s algorithm cipher test failed' % algo @@ -65,7 +68,8 @@ class CipherStreamTestCase(unittest.TestCase): for i in ciphers: self.try_algo(i) - self.assertRaises(ValueError, self.try_algo, 'nosuchalgo4567') + with self.assertRaises(ValueError): + self.try_algo('nosuchalgo4567') def suite(): suite = unittest.TestSuite() |