@@ -206,15 +206,17 @@ def decode_failure(blob):
206206 try :
207207 buffer = base64 .b64decode (blob )
208208 except Exception :
209- raise InvalidArgument (f"Invalid base64 encoded string: { blob !r} " )
209+ raise InvalidArgument (f"Invalid base64 encoded string: { blob !r} " ) from None
210210 prefix = buffer [:1 ]
211211 if prefix == b"\0 " :
212212 return buffer [1 :]
213213 elif prefix == b"\1 " :
214214 try :
215215 return zlib .decompress (buffer [1 :])
216- except zlib .error :
217- raise InvalidArgument (f"Invalid zlib compression for blob { blob !r} " )
216+ except zlib .error as err :
217+ raise InvalidArgument (
218+ f"Invalid zlib compression for blob { blob !r} "
219+ ) from err
218220 else :
219221 raise InvalidArgument (
220222 f"Could not decode blob { blob !r} : Invalid start byte { prefix !r} "
@@ -724,7 +726,7 @@ def _execute_once_for_engine(self, data):
724726 # This can happen if an error occurred in a finally
725727 # block somewhere, suppressing our original StopTest.
726728 # We raise a new one here to resume normal operation.
727- raise StopTest (data .testcounter )
729+ raise StopTest (data .testcounter ) from e
728730 else :
729731 # The test failed by raising an exception, so we inform the
730732 # engine that this test run was interesting. This is the normal
@@ -1107,13 +1109,13 @@ def wrapped_test(*arguments, **kwargs):
11071109 "The shape of the test data has changed in some way "
11081110 "from where this blob was defined. Are you sure "
11091111 "you're running the same test?"
1110- )
1112+ ) from None
11111113 except UnsatisfiedAssumption :
11121114 raise DidNotReproduce (
11131115 "The test data failed to satisfy an assumption in the "
11141116 "test. Have you added it since this blob was "
11151117 "generated?"
1116- )
1118+ ) from None
11171119
11181120 # There was no @reproduce_failure, so start by running any explicit
11191121 # examples from @example decorators.
0 commit comments