@@ -45,8 +45,9 @@ async def test_get_aerospike_client_error(self, aero):
4545 client_mock .connect = MagicMock (side_effect = Exception )
4646 faust .stores .aerospike .aerospike_client = None
4747 config = {"k" : "v" }
48- with pytest .raises (Exception ):
48+ with pytest .raises (Exception ) as exc_info :
4949 AeroSpikeStore .get_aerospike_client (config )
50+ assert exc_info .type == Exception
5051
5152 @pytest .mark .asyncio
5253 async def test_get_aerospike_client_instantiated (self , aero ):
@@ -90,8 +91,9 @@ def test_get_none_value(self, store):
9091
9192 def test_get_exception (self , store ):
9293 store .client .get = MagicMock (side_effect = Exception )
93- with pytest .raises (Exception ):
94+ with pytest .raises (Exception ) as exc_info :
9495 store ._get (b"test_get" )
96+ assert exc_info .type == Exception
9597
9698 def test_set_success (
9799 self ,
@@ -119,8 +121,9 @@ def test_set_exception(self, store):
119121 store .client .put = MagicMock (side_effect = Exception )
120122 key = b"key"
121123 value = b"value"
122- with pytest .raises (Exception ):
124+ with pytest .raises (Exception ) as exc_info :
123125 store ._set (key , value )
126+ assert exc_info .type == Exception
124127
125128 def test_persisted_offset (self , store ):
126129 return_value = store .persisted_offset (MagicMock ())
@@ -136,15 +139,17 @@ def test_del_success(self, store):
136139 def test_del_exception (self , store ):
137140 key = b"key"
138141 store .client .remove = MagicMock (side_effect = Exception )
139- with pytest .raises (Exception ):
142+ with pytest .raises (Exception ) as exc_info :
140143 store ._del (key )
144+ assert exc_info .type == Exception
141145
142146 def test_iterkeys_error (self , store ):
143147 scan = MagicMock ()
144148 store .client .scan = MagicMock (side_effect = Exception )
145149 scan .results = MagicMock (side_effect = Exception )
146- with pytest .raises (Exception ):
150+ with pytest .raises (Exception ) as exc_info :
147151 list (store ._iterkeys ())
152+ assert exc_info .type == Exception
148153
149154 def test_iterkeys_success (self , store ):
150155 scan = MagicMock ()
@@ -181,13 +186,15 @@ def test_itervalues_success(self, store):
181186
182187 def test_itervalues_error (self , store ):
183188 store .client .scan = MagicMock (side_effect = Exception )
184- with pytest .raises (Exception ):
189+ with pytest .raises (Exception ) as exc_info :
185190 set (store ._itervalues ())
191+ assert exc_info .type == Exception
186192
187193 def test_iteritems_error (self , store ):
188194 store .client .scan = MagicMock (side_effect = Exception )
189- with pytest .raises (Exception ):
195+ with pytest .raises (Exception ) as exc_info :
190196 set (store ._iteritems ())
197+ assert exc_info .type == Exception
191198
192199 def test_iteritems_success (self , store ):
193200 with patch ("faust.stores.aerospike.aerospike" , MagicMock ()):
@@ -218,8 +225,9 @@ def test_iteritems_success(self, store):
218225 def test_contains_error (self , store ):
219226 store .client .exists = MagicMock (side_effect = Exception )
220227 key = b"key"
221- with pytest .raises (Exception ):
228+ with pytest .raises (Exception ) as exc_info :
222229 store ._contains (key )
230+ assert exc_info .type == Exception
223231
224232 def test_contains_does_not_exist (self , store ):
225233 store .client .exists = MagicMock (return_value = (None , None ))
0 commit comments