File tree Expand file tree Collapse file tree 2 files changed +20
-2
lines changed
Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change 33
44from six import PY2
55from threading import Thread , currentThread
6- from riak .transports .pool import Pool , BadResource
76from random import SystemRandom
87from time import sleep
8+
9+ from riak import RiakError
910from riak .tests import RUN_POOL
1011from riak .tests .comparison import Comparison
12+ from riak .transports .pool import Pool , BadResource
1113
1214if PY2 :
1315 from Queue import Queue
@@ -36,6 +38,21 @@ def create_resource(self):
3638@unittest .skipUnless (RUN_POOL , 'RUN_POOL is 0' )
3739class PoolTest (unittest .TestCase , Comparison ):
3840
41+ def test_can_raise_bad_resource (self ):
42+ ex_msg = 'exception-message!'
43+ with self .assertRaises (BadResource ) as cm :
44+ raise BadResource (ex_msg )
45+ ex = cm .exception
46+ self .assertEqual (ex .args [0 ], ex_msg )
47+
48+ def test_bad_resource_inner_exception (self ):
49+ ex_msg = 'exception-message!'
50+ ex = RiakError (ex_msg )
51+ with self .assertRaises (BadResource ) as cm :
52+ raise BadResource (ex )
53+ br_ex = cm .exception
54+ self .assertEqual (br_ex .args [0 ], ex )
55+
3956 def test_yields_new_object_when_empty (self ):
4057 """
4158 The pool should create new resources as needed.
Original file line number Diff line number Diff line change @@ -186,7 +186,8 @@ def _recv(self, msglen):
186186 # https://docs.python.org/2/howto/sockets.html#using-a-socket
187187 # https://github.com/basho/riak-python-client/issues/399
188188 if nbytes == 0 :
189- raise BadResource ('recv_into returned zero bytes unexpectedly' )
189+ ex = RiakError ('recv_into returned zero bytes unexpectedly' )
190+ raise BadResource (ex )
190191 view = view [nbytes :] # slicing views is cheap
191192 toread -= nbytes
192193 nread += nbytes
You can’t perform that action at this time.
0 commit comments