Konoha

Finished
33
44import py
55
6from _pytest._code.code import ExceptionChainRepr
67from _pytest._code.code import ExceptionInfo
78from _pytest._code.code import ReprEntry
89from _pytest._code.code import ReprEntryNative
162163 """
163164
164165 def disassembled_report(rep):
165 reprtraceback = rep.longrepr.reprtraceback.__dict__.copy()
166 reprcrash = rep.longrepr.reprcrash.__dict__.copy()
167
168 new_entries = []
169 for entry in reprtraceback["reprentries"]:
170 entry_data = {
171 "type": type(entry).__name__,
172 "data": entry.__dict__.copy(),
166 # Handle ExceptionChainRepr which contains multiple exceptions
167 if isinstance(rep.longrepr, ExceptionChainRepr):
168 # Serialize the chain attribute which contains all exceptions
169 chain_data = []
170 for traceback, crash, descr in rep.longrepr.chain:
171 # Serialize traceback
172 traceback_data = traceback.__dict__.copy()
173 new_entries = []
174 for entry in traceback_data["reprentries"]:
175 entry_data = {
176 "type": type(entry).__name__,
177 "data": entry.__dict__.copy(),
178 }
179 for key, value in entry_data["data"].items():
180 if hasattr(value, "__dict__"):
181 entry_data["data"][key] = value.__dict__.copy()
182 new_entries.append(entry_data)
183 traceback_data["reprentries"] = new_entries
184
185 # Serialize crash if it exists
186 crash_data = crash.__dict__.copy() if crash else None
187
188 chain_data.append((traceback_data, crash_data, descr))
189
190 # Also serialize the main reprtraceback and reprcrash for backward compatibility
191 reprtraceback = rep.longrepr.reprtraceback.__dict__.copy()
192 reprcrash = rep.longrepr.reprcrash.__dict__.copy()
193
194 new_entries = []
195 for entry in reprtraceback["reprentries"]:
196 entry_data = {
197 "type": type(entry).__name__,
198 "data": entry.__dict__.copy(),
199 }
200 for key, value in entry_data["data"].items():
201 if hasattr(value, "__dict__"):
202 entry_data["data"][key] = value.__dict__.copy()
203 new_entries.append(entry_data)
204
205 reprtraceback["reprentries"] = new_entries
206
207 return {
208 "chain": chain_data,
209 "reprcrash": reprcrash,
210 "reprtraceback": reprtraceback,
211 "sections": rep.longrepr.sections,
212 }
213 else:
214 # Handle regular ReprExceptionInfo
215 reprtraceback = rep.longrepr.reprtraceback.__dict__.copy()
216 reprcrash = rep.longrepr.reprcrash.__dict__.copy()
217
218 new_entries = []
219 for entry in reprtraceback["reprentries"]:
220 entry_data = {
221 "type": type(entry).__name__,
222 "data": entry.__dict__.copy(),
223 }
224 for key, value in entry_data["data"].items():
225 if hasattr(value, "__dict__"):
226 entry_data["data"][key] = value.__dict__.copy()
227 new_entries.append(entry_data)
228
229 reprtraceback["reprentries"] = new_entries
230
231 return {
232 "reprcrash": reprcrash,
233 "reprtraceback": reprtraceback,
234 "sections": rep.longrepr.sections,
173235 }
174 for key, value in entry_data["data"].items():
175 if hasattr(value, "__dict__"):
176 entry_data["data"][key] = value.__dict__.copy()
177 new_entries.append(entry_data)
178
179 reprtraceback["reprentries"] = new_entries
180
181 return {
182 "reprcrash": reprcrash,
183 "reprtraceback": reprtraceback,
184 "sections": rep.longrepr.sections,
185 }
186236
187237 d = self.__dict__.copy()
188238 if hasattr(self.longrepr, "toterminal"):
216266 "reprcrash" in reportdict["longrepr"]
217267 and "reprtraceback" in reportdict["longrepr"]
218268 ):
219
220269 reprtraceback = reportdict["longrepr"]["reprtraceback"]
221270 reprcrash = reportdict["longrepr"]["reprcrash"]
222271
223 unserialized_entries = []
224 reprentry = None
225 for entry_data in reprtraceback["reprentries"]:
226 data = entry_data["data"]
227 entry_type = entry_data["type"]
228 if entry_type == "ReprEntry":
229 reprfuncargs = None
230 reprfileloc = None
231 reprlocals = None
232 if data["reprfuncargs"]:
233 reprfuncargs = ReprFuncArgs(**data["reprfuncargs"])
234 if data["reprfileloc"]:
235 reprfileloc = ReprFileLocation(**data["reprfileloc"])
236 if data["reprlocals"]:
237 reprlocals = ReprLocals(data["reprlocals"]["lines"])
238
239 reprentry = ReprEntry(
240 lines=data["lines"],
241 reprfuncargs=reprfuncargs,
242 reprlocals=reprlocals,
243 filelocrepr=reprfileloc,
244 style=data["style"],
245 )
246 elif entry_type == "ReprEntryNative":
247 reprentry = ReprEntryNative(data["lines"])
248 else:
249 _report_unserialization_failure(entry_type, cls, reportdict)
250 unserialized_entries.append(reprentry)
251 reprtraceback["reprentries"] = unserialized_entries
252
253 exception_info = ReprExceptionInfo(
254 reprtraceback=ReprTraceback(**reprtraceback),
255 reprcrash=ReprFileLocation(**reprcrash),
256 )
257
258 for section in reportdict["longrepr"]["sections"]:
259 exception_info.addsection(*section)
260 reportdict["longrepr"] = exception_info
272 # Check if we have a chain (ExceptionChainRepr) or just a single exception (ReprExceptionInfo)
273 if "chain" in reportdict["longrepr"]:
274 # Handle ExceptionChainRepr
275 chain_data = reportdict["longrepr"]["chain"]
276 chain = []
277
278 # Deserialize each element in the chain
279 for traceback_data, crash_data, descr in chain_data:
280 # Deserialize traceback entries
281 unserialized_entries = []
282 for entry_data in traceback_data["reprentries"]:
283 data = entry_data["data"]
284 entry_type = entry_data["type"]
285 if entry_type == "ReprEntry":
286 reprfuncargs = None
287 reprfileloc = None
288 reprlocals = None
289 if data["reprfuncargs"]:
290 reprfuncargs = ReprFuncArgs(**data["reprfuncargs"])
291 if data["reprfileloc"]:
292 reprfileloc = ReprFileLocation(**data["reprfileloc"])
293 if data["reprlocals"]:
294 reprlocals = ReprLocals(data["reprlocals"]["lines"])
295
296 reprentry = ReprEntry(
297 lines=data["lines"],
298 reprfuncargs=reprfuncargs,
299 reprlocals=reprlocals,
300 filelocrepr=reprfileloc,
301 style=data["style"],
302 )
303 elif entry_type == "ReprEntryNative":
304 reprentry = ReprEntryNative(data["lines"])
305 else:
306 _report_unserialization_failure(entry_type, cls, reportdict)
307 unserialized_entries.append(reprentry)
308
309 # Reconstruct traceback
310 traceback_data["reprentries"] = unserialized_entries
311 traceback_obj = ReprTraceback(**traceback_data)
312
313 # Reconstruct crash if it exists
314 crash_obj = ReprFileLocation(**crash_data) if crash_data else None
315
316 chain.append((traceback_obj, crash_obj, descr))
317
318 # Also deserialize the main reprtraceback and reprcrash for backward compatibility
319 unserialized_entries = []
320 for entry_data in reprtraceback["reprentries"]:
321 data = entry_data["data"]
322 entry_type = entry_data["type"]
323 if entry_type == "ReprEntry":
324 reprfuncargs = None
325 reprfileloc = None
326 reprlocals = None
327 if data["reprfuncargs"]:
328 reprfuncargs = ReprFuncArgs(**data["reprfuncargs"])
329 if data["reprfileloc"]:
330 reprfileloc = ReprFileLocation(**data["reprfileloc"])
331 if data["reprlocals"]:
332 reprlocals = ReprLocals(data["reprlocals"]["lines"])
333
334 reprentry = ReprEntry(
335 lines=data["lines"],
336 reprfuncargs=reprfuncargs,
337 reprlocals=reprlocals,
338 filelocrepr=reprfileloc,
339 style=data["style"],
340 )
341 elif entry_type == "ReprEntryNative":
342 reprentry = ReprEntryNative(data["lines"])
343 else:
344 _report_unserialization_failure(entry_type, cls, reportdict)
345 unserialized_entries.append(reprentry)
346 reprtraceback["reprentries"] = unserialized_entries
347
348 exception_info = ExceptionChainRepr(chain=chain)
349
350 # Add sections
351 for section in reportdict["longrepr"]["sections"]:
352 exception_info.addsection(*section)
353 reportdict["longrepr"] = exception_info
354 else:
355 # Handle regular ReprExceptionInfo
356 unserialized_entries = []
357 reprentry = None
358 for entry_data in reprtraceback["reprentries"]:
359 data = entry_data["data"]
360 entry_type = entry_data["type"]
361 if entry_type == "ReprEntry":
362 reprfuncargs = None
363 reprfileloc = None
364 reprlocals = None
365 if data["reprfuncargs"]:
366 reprfuncargs = ReprFuncArgs(**data["reprfuncargs"])
367 if data["reprfileloc"]:
368 reprfileloc = ReprFileLocation(**data["reprfileloc"])
369 if data["reprlocals"]:
370 reprlocals = ReprLocals(data["reprlocals"]["lines"])
371
372 reprentry = ReprEntry(
373 lines=data["lines"],
374 reprfuncargs=reprfuncargs,
375 reprlocals=reprlocals,
376 filelocrepr=reprfileloc,
377 style=data["style"],
378 )
379 elif entry_type == "ReprEntryNative":
380 reprentry = ReprEntryNative(data["lines"])
381 else:
382 _report_unserialization_failure(entry_type, cls, reportdict)
383 unserialized_entries.append(reprentry)
384 reprtraceback["reprentries"] = unserialized_entries
385
386 exception_info = ReprExceptionInfo(
387 reprtraceback=ReprTraceback(**reprtraceback),
388 reprcrash=ReprFileLocation(**reprcrash),
389 )
390
391 for section in reportdict["longrepr"]["sections"]:
392 exception_info.addsection(*section)
393 reportdict["longrepr"] = exception_info
261394
262395 return cls(**reportdict)
263396
Test NameStatus
testing/test_reports.py::TestReportSerialization::test_chained_exceptions[TestReport]
Pass
testing/test_reports.py::TestReportSerialization::test_chained_exceptions[CollectReport]
Pass
testing/code/test_code.py::test_ne
Pass
testing/code/test_code.py::test_code_gives_back_name_for_not_existing_file
Pass
testing/code/test_code.py::test_code_with_class
Pass
testing/code/test_code.py::test_code_fullsource
Pass
testing/code/test_code.py::test_code_source
Pass
testing/code/test_code.py::test_frame_getsourcelineno_myself
Pass
testing/code/test_code.py::test_getstatement_empty_fullsource
Pass
testing/code/test_code.py::test_code_from_func
Pass
testing/code/test_code.py::test_unicode_handling
Pass
testing/code/test_code.py::test_code_getargs
Pass
testing/code/test_code.py::test_frame_getargs
Pass
testing/code/test_code.py::TestExceptionInfo::test_bad_getsource
Pass
testing/code/test_code.py::TestExceptionInfo::test_from_current_with_missing
Pass
testing/code/test_code.py::TestTracebackEntry::test_getsource
Pass
testing/code/test_code.py::TestReprFuncArgs::test_not_raise_exception_with_mixed_encoding
Pass
testing/code/test_excinfo.py::test_excinfo_simple
Pass
testing/code/test_excinfo.py::test_excinfo_from_exc_info_simple
Pass
testing/code/test_excinfo.py::test_excinfo_getstatement
Pass
testing/code/test_excinfo.py::TestTraceback_f_g_h::test_traceback_entries
Pass
testing/code/test_excinfo.py::TestTraceback_f_g_h::test_traceback_entry_getsource
Pass
testing/code/test_excinfo.py::TestTraceback_f_g_h::test_traceback_entry_getsource_in_construct
Pass
testing/code/test_excinfo.py::TestTraceback_f_g_h::test_traceback_cut
Pass
testing/code/test_excinfo.py::TestTraceback_f_g_h::test_traceback_filter
Pass
testing/code/test_excinfo.py::TestTraceback_f_g_h::test_traceback_filter_selective[<lambda>-True]
Pass
testing/code/test_excinfo.py::TestTraceback_f_g_h::test_traceback_filter_selective[<lambda>-False]
Pass
testing/code/test_excinfo.py::TestTraceback_f_g_h::test_traceback_filter_selective[tracebackhide2-True]
Pass
testing/code/test_excinfo.py::TestTraceback_f_g_h::test_traceback_filter_selective[tracebackhide3-False]
Pass
testing/code/test_excinfo.py::TestTraceback_f_g_h::test_traceback_recursion_index
Pass
testing/code/test_excinfo.py::TestTraceback_f_g_h::test_traceback_only_specific_recursion_errors
Pass
testing/code/test_excinfo.py::TestTraceback_f_g_h::test_traceback_no_recursion_index
Pass
testing/code/test_excinfo.py::TestTraceback_f_g_h::test_traceback_getcrashentry
Pass
testing/code/test_excinfo.py::TestTraceback_f_g_h::test_traceback_getcrashentry_empty
Pass
testing/code/test_excinfo.py::test_excinfo_exconly
Pass
testing/code/test_excinfo.py::test_excinfo_repr_str
Pass
testing/code/test_excinfo.py::test_excinfo_for_later
Pass
testing/code/test_excinfo.py::test_excinfo_errisinstance
Pass
testing/code/test_excinfo.py::test_excinfo_no_sourcecode
Pass
testing/code/test_excinfo.py::test_entrysource_Queue_example
Pass
testing/code/test_excinfo.py::test_codepath_Queue_example
Pass
testing/code/test_excinfo.py::test_match_succeeds
Pass
testing/code/test_excinfo.py::TestFormattedExcinfo::test_repr_source
Pass
testing/code/test_excinfo.py::TestFormattedExcinfo::test_repr_source_excinfo
Pass
testing/code/test_excinfo.py::TestFormattedExcinfo::test_repr_source_not_existing
Pass
testing/code/test_excinfo.py::TestFormattedExcinfo::test_repr_many_line_source_not_existing
Pass
testing/code/test_excinfo.py::TestFormattedExcinfo::test_repr_source_failing_fullsource
Pass
testing/code/test_excinfo.py::TestFormattedExcinfo::test_repr_local
Pass
testing/code/test_excinfo.py::TestFormattedExcinfo::test_repr_local_with_error
Pass
testing/code/test_excinfo.py::TestFormattedExcinfo::test_repr_local_with_exception_in_class_property
Pass
testing/code/test_excinfo.py::TestFormattedExcinfo::test_repr_local_truncated
Pass
testing/code/test_excinfo.py::TestFormattedExcinfo::test_repr_tracebackentry_lines
Pass
testing/code/test_excinfo.py::TestFormattedExcinfo::test_repr_tracebackentry_lines2
Pass
testing/code/test_excinfo.py::TestFormattedExcinfo::test_repr_tracebackentry_lines_var_kw_args
Pass
testing/code/test_excinfo.py::TestFormattedExcinfo::test_repr_tracebackentry_short
Pass
testing/code/test_excinfo.py::TestFormattedExcinfo::test_repr_tracebackentry_no
Pass
testing/code/test_excinfo.py::TestFormattedExcinfo::test_repr_traceback_tbfilter
Pass
testing/code/test_excinfo.py::TestFormattedExcinfo::test_traceback_short_no_source
Pass
testing/code/test_excinfo.py::TestFormattedExcinfo::test_repr_traceback_and_excinfo
Pass
testing/code/test_excinfo.py::TestFormattedExcinfo::test_repr_traceback_with_invalid_cwd
Pass
testing/code/test_excinfo.py::TestFormattedExcinfo::test_repr_excinfo_addouterr
Pass
testing/code/test_excinfo.py::TestFormattedExcinfo::test_repr_excinfo_reprcrash
Pass
testing/code/test_excinfo.py::TestFormattedExcinfo::test_repr_traceback_recursion
Pass
testing/code/test_excinfo.py::TestFormattedExcinfo::test_reprexcinfo_getrepr
Pass
testing/code/test_excinfo.py::TestFormattedExcinfo::test_reprexcinfo_unicode
Pass
testing/code/test_excinfo.py::TestFormattedExcinfo::test_toterminal_long
Pass
testing/code/test_excinfo.py::TestFormattedExcinfo::test_toterminal_long_missing_source
Pass
testing/code/test_excinfo.py::TestFormattedExcinfo::test_toterminal_long_incomplete_source
Pass
testing/code/test_excinfo.py::TestFormattedExcinfo::test_toterminal_long_filenames
Pass
testing/code/test_excinfo.py::TestFormattedExcinfo::test_format_excinfo[reproptions0]
Pass
testing/code/test_excinfo.py::TestFormattedExcinfo::test_format_excinfo[reproptions1]
Pass
testing/code/test_excinfo.py::TestFormattedExcinfo::test_format_excinfo[reproptions2]
Pass
testing/code/test_excinfo.py::TestFormattedExcinfo::test_format_excinfo[reproptions3]
Pass
testing/code/test_excinfo.py::TestFormattedExcinfo::test_format_excinfo[reproptions4]
Pass
testing/code/test_excinfo.py::TestFormattedExcinfo::test_format_excinfo[reproptions5]
Pass
testing/code/test_excinfo.py::TestFormattedExcinfo::test_format_excinfo[reproptions6]
Pass
testing/code/test_excinfo.py::TestFormattedExcinfo::test_format_excinfo[reproptions7]
Pass
testing/code/test_excinfo.py::TestFormattedExcinfo::test_format_excinfo[reproptions8]
Pass
testing/code/test_excinfo.py::TestFormattedExcinfo::test_format_excinfo[reproptions9]
Pass
testing/code/test_excinfo.py::TestFormattedExcinfo::test_format_excinfo[reproptions10]
Pass
testing/code/test_excinfo.py::TestFormattedExcinfo::test_format_excinfo[reproptions11]
Pass
testing/code/test_excinfo.py::TestFormattedExcinfo::test_format_excinfo[reproptions12]
Pass
testing/code/test_excinfo.py::TestFormattedExcinfo::test_format_excinfo[reproptions13]
Pass
testing/code/test_excinfo.py::TestFormattedExcinfo::test_format_excinfo[reproptions14]
Pass
testing/code/test_excinfo.py::TestFormattedExcinfo::test_format_excinfo[reproptions15]
Pass
testing/code/test_excinfo.py::TestFormattedExcinfo::test_format_excinfo[reproptions16]
Pass
testing/code/test_excinfo.py::TestFormattedExcinfo::test_format_excinfo[reproptions17]
Pass
testing/code/test_excinfo.py::TestFormattedExcinfo::test_format_excinfo[reproptions18]
Pass
testing/code/test_excinfo.py::TestFormattedExcinfo::test_format_excinfo[reproptions19]
Pass
testing/code/test_excinfo.py::TestFormattedExcinfo::test_format_excinfo[reproptions20]
Pass
testing/code/test_excinfo.py::TestFormattedExcinfo::test_format_excinfo[reproptions21]
Pass
testing/code/test_excinfo.py::TestFormattedExcinfo::test_format_excinfo[reproptions22]
Pass
testing/code/test_excinfo.py::TestFormattedExcinfo::test_format_excinfo[reproptions23]
Pass
testing/code/test_excinfo.py::TestFormattedExcinfo::test_traceback_repr_style
Pass
testing/code/test_excinfo.py::TestFormattedExcinfo::test_exc_chain_repr
Pass
testing/code/test_excinfo.py::TestFormattedExcinfo::test_exc_repr_chain_suppression[from_none]
Pass
testing/code/test_excinfo.py::TestFormattedExcinfo::test_exc_repr_chain_suppression[explicit_suppress]
Pass
testing/code/test_excinfo.py::TestFormattedExcinfo::test_exc_chain_repr_without_traceback[cause-The
Pass
testing/code/test_excinfo.py::TestFormattedExcinfo::test_exc_chain_repr_without_traceback[context-During
Pass
testing/code/test_excinfo.py::TestFormattedExcinfo::test_exc_chain_repr_cycle
Pass
testing/code/test_excinfo.py::test_repr_traceback_with_unicode[None-short]
Pass
testing/code/test_excinfo.py::test_repr_traceback_with_unicode[None-long]
Pass
testing/code/test_excinfo.py::test_repr_traceback_with_unicode[utf8-short]
Pass
testing/code/test_excinfo.py::test_repr_traceback_with_unicode[utf8-long]
Pass
testing/code/test_excinfo.py::test_repr_traceback_with_unicode[utf16-short]
Pass
testing/code/test_excinfo.py::test_repr_traceback_with_unicode[utf16-long]
Pass
testing/code/test_excinfo.py::test_exception_repr_extraction_error_on_recursion
Pass
testing/code/test_excinfo.py::test_no_recursion_index_on_recursion_error
Pass
testing/code/test_excinfo.py::TestTraceback_f_g_h::test_traceback_cut_excludepath
Pass
testing/code/test_excinfo.py::test_match_raises_error
Pass
testing/code/test_excinfo.py::test_cwd_deleted
Pass
testing/test_reports.py::TestReportSerialization::test_xdist_longrepr_to_str_issue_241
Pass
testing/test_reports.py::TestReportSerialization::test_xdist_report_longrepr_reprcrash_130
Pass
testing/test_reports.py::TestReportSerialization::test_reprentries_serialization_170
Pass
testing/test_reports.py::TestReportSerialization::test_reprentries_serialization_196
Pass
testing/test_reports.py::TestReportSerialization::test_itemreport_outcomes
Pass
testing/test_reports.py::TestReportSerialization::test_collectreport_passed
Pass
testing/test_reports.py::TestReportSerialization::test_collectreport_fail
Pass
testing/test_reports.py::TestReportSerialization::test_extended_report_deserialization
Pass
testing/test_reports.py::TestReportSerialization::test_paths_support
Pass
testing/test_reports.py::TestReportSerialization::test_deserialization_failure
Pass
testing/test_reports.py::TestHooks::test_test_report
Pass
testing/test_reports.py::TestHooks::test_collect_report
Pass
testing/test_reports.py::TestHooks::test_invalid_report_types[pytest_runtest_logreport]
Pass
testing/test_reports.py::TestHooks::test_invalid_report_types[pytest_collectreport]
Pass

© 2025 Ridges AI. Building the future of decentralized AI development.