summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Marshall <catchjosh@gmail.com>2015-10-05 17:26:46 -0700
committerJoshua Marshall <catchjosh@gmail.com>2015-10-05 17:26:46 -0700
commit402fe6a876d57eb17490f213f5154a3fc018d0c9 (patch)
treec90ec13deb02a9c2acd9f4e8180f2df86042e146
parenta39d1f9debff84b2097a2788896ad61867ad1a0e (diff)
downloadjsonrpclib-402fe6a876d57eb17490f213f5154a3fc018d0c9.tar.gz
Fixing assert contexts for <= 2.6 / unittest2
-rw-r--r--tests.py17
1 files changed, 9 insertions, 8 deletions
diff --git a/tests.py b/tests.py
index 386275e..a1d874a 100644
--- a/tests.py
+++ b/tests.py
@@ -107,7 +107,9 @@ class TestCompatibility(unittest.TestCase):
self.assertTrue(response == verify_response)
def test_non_existent_method(self):
- self.assertRaises(ProtocolError, self.client.foobar)
+ with self.assertRaises(ProtocolError):
+ self.client.foobar()
+
request = json.loads(history.request)
response = json.loads(history.response)
verify_request = {
@@ -304,7 +306,8 @@ class InternalTests(unittest.TestCase):
def test_single_kwargs_and_args(self):
client = self.get_client()
- self.assertRaises(ProtocolError, client.add, (5,), {'y': 10})
+ with self.assertRaises(ProtocolError):
+ client.add(5, y=10)
def test_single_notify(self):
client = self.get_client()
@@ -351,7 +354,8 @@ class InternalTests(unittest.TestCase):
else:
def func():
return result[i]
- self.assertRaises(raises[i], func)
+ with self.assertRaises(raises[i]):
+ func()
if jsonrpc.USE_UNIX_SOCKETS:
@@ -401,11 +405,8 @@ class UnixSocketErrorTests(unittest.TestCase):
def test_client(self):
address = "unix://shouldnt/work.sock"
- self.assertRaises(
- jsonrpc.UnixSocketMissing,
- Server,
- address
- )
+ with self.assertRaises(jsonrpc.UnixSocketMissing):
+ Server(address)
def tearDown(self):
jsonrpc.USE_UNIX_SOCKETS = self.original_value