File tree 2 files changed +20
-2
lines changed 2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change 3
3
4
4
from six import PY2
5
5
from threading import Thread , currentThread
6
- from riak .transports .pool import Pool , BadResource
7
6
from random import SystemRandom
8
7
from time import sleep
8
+
9
+ from riak import RiakError
9
10
from riak .tests import RUN_POOL
10
11
from riak .tests .comparison import Comparison
12
+ from riak .transports .pool import Pool , BadResource
11
13
12
14
if PY2 :
13
15
from Queue import Queue
@@ -36,6 +38,21 @@ def create_resource(self):
36
38
@unittest .skipUnless (RUN_POOL , 'RUN_POOL is 0' )
37
39
class PoolTest (unittest .TestCase , Comparison ):
38
40
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
+
39
56
def test_yields_new_object_when_empty (self ):
40
57
"""
41
58
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):
186
186
# https://docs.python.org/2/howto/sockets.html#using-a-socket
187
187
# https://github.com/basho/riak-python-client/issues/399
188
188
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 )
190
191
view = view [nbytes :] # slicing views is cheap
191
192
toread -= nbytes
192
193
nread += nbytes
You can’t perform that action at this time.
0 commit comments