@@ -167,23 +167,41 @@ def updateResult(self, result):
167
167
result .addSkip (self .test , self .reason )
168
168
169
169
170
+ def fixup_fake_exception (fake_exc ):
171
+ ex = fake_exc [2 ]
172
+ if ex .tb_frame .f_code .positions is None :
173
+ return
174
+ while ex is not None :
175
+ # .co_positions is supposed to be a function that returns an enumerable
176
+ # to the list of code positions. Create a function object wrapper around
177
+ # the data
178
+ def make_wrapper (rtn ):
179
+ return lambda : rtn
180
+ ex .tb_frame .f_code .co_positions = make_wrapper (ex .tb_frame .f_code .positions )
181
+ ex = ex .tb_next
182
+
183
+
170
184
class BufferedTestFailure (BufferedTestBase ):
171
185
def updateResult (self , result ):
186
+ fixup_fake_exception (self .error )
172
187
result .addFailure (self .test , self .error )
173
188
174
189
175
190
class BufferedTestExpectedFailure (BufferedTestBase ):
176
191
def updateResult (self , result ):
192
+ fixup_fake_exception (self .error )
177
193
result .addExpectedFailure (self .test , self .error )
178
194
179
195
180
196
class BufferedTestError (BufferedTestBase ):
181
197
def updateResult (self , result ):
198
+ fixup_fake_exception (self .error )
182
199
result .addError (self .test , self .error )
183
200
184
201
185
202
class BufferedTestUnexpectedSuccess (BufferedTestBase ):
186
203
def updateResult (self , result ):
204
+ fixup_fake_exception (self .error )
187
205
result .addUnexpectedSuccess (self .test )
188
206
189
207
@@ -203,6 +221,7 @@ def __init__(self, tb):
203
221
self .tb_frame = FakeFrame (tb .tb_frame )
204
222
self .tb_lineno = tb .tb_lineno
205
223
self .tb_next = FakeTraceback (tb .tb_next ) if tb .tb_next is not None else None
224
+ self .tb_lasti = tb .tb_lasti
206
225
207
226
208
227
class FakeFrame ():
@@ -216,6 +235,12 @@ class FakeCode():
216
235
def __init__ (self , co ):
217
236
self .co_filename = co .co_filename
218
237
self .co_name = co .co_name
238
+ # co.co_positions() returns an iterator. Flatten it to a list so that it can
239
+ # be pickled to the parent process
240
+ if hasattr (co , 'co_positions' ):
241
+ self .positions = list (co .co_positions ())
242
+ else :
243
+ self .positions = None
219
244
220
245
221
246
def num_cores ():
0 commit comments