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_ssl_offline.py | |
parent | 835a98cc13e5f451cc3a45446412063f110a676e (diff) | |
download | m2crypto-f45b71b10e0fc1580e32a9e98b7dceefa13f1cec.tar.gz |
Change self.assertRaises to context managers.
Diffstat (limited to 'tests/test_ssl_offline.py')
-rw-r--r-- | tests/test_ssl_offline.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/tests/test_ssl_offline.py b/tests/test_ssl_offline.py index 865175f..d862036 100644 --- a/tests/test_ssl_offline.py +++ b/tests/test_ssl_offline.py @@ -24,7 +24,8 @@ class CheckerTestCase(unittest.TestCase): peerCertHash='6D5C51BF6C90686A87E015A07731B252B7638D93') x509 = X509.load_cert('tests/server.pem') assert check(x509, srv_host) - self.assertRaises(Checker.WrongHost, check, x509, 'example.com') + with self.assertRaises(Checker.WrongHost): + check(x509, 'example.com') doctest.testmod(Checker) @@ -32,7 +33,8 @@ class CheckerTestCase(unittest.TestCase): class ContextTestCase(unittest.TestCase): def test_ctx_load_verify_locations(self): ctx = SSL.Context() - self.assertRaises(ValueError, ctx.load_verify_locations, None, None) + with self.assertRaises(ValueError): + ctx.load_verify_locations(None, None) def test_map(self): from M2Crypto.SSL.Context import map, _ctxmap |