xas

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 (chained exceptions)
167 print(f"DEBUG: disassembled_report called, hasattr chain: {hasattr(rep.longrepr, 'chain')}")
168 if hasattr(rep.longrepr, "chain"):
169 chain_data = []
170 for reprtraceback, reprcrash, descr in rep.longrepr.chain:
171 # Serialize reprtraceback
172 rt_dict = reprtraceback.__dict__.copy()
173 new_entries = []
174 for entry in rt_dict["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 rt_dict["reprentries"] = new_entries
184
185 # Serialize reprcrash
186 rc_dict = reprcrash.__dict__.copy() if reprcrash else None
187
188 chain_data.append({
189 "reprtraceback": rt_dict,
190 "reprcrash": rc_dict,
191 "descr": descr
192 })
193
194 return {
195 "repr_type": "ExceptionChainRepr",
196 "chain": chain_data,
197 "sections": rep.longrepr.sections,
198 }
199 else:
200 # Handle regular ReprExceptionInfo
201 reprtraceback = rep.longrepr.reprtraceback.__dict__.copy()
202 reprcrash = rep.longrepr.reprcrash.__dict__.copy()
203
204 new_entries = []
205 for entry in reprtraceback["reprentries"]:
206 entry_data = {
207 "type": type(entry).__name__,
208 "data": entry.__dict__.copy(),
209 }
210 for key, value in entry_data["data"].items():
211 if hasattr(value, "__dict__"):
212 entry_data["data"][key] = value.__dict__.copy()
213 new_entries.append(entry_data)
214
215 reprtraceback["reprentries"] = new_entries
216
217 return {
218 "repr_type": "ReprExceptionInfo",
219 "reprcrash": reprcrash,
220 "reprtraceback": reprtraceback,
221 "sections": rep.longrepr.sections,
173222 }
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 }
186223
187224 d = self.__dict__.copy()
225 print(f"DEBUG: _to_json called, hasattr toterminal: {hasattr(self.longrepr, 'toterminal')}")
188226 if hasattr(self.longrepr, "toterminal"):
189 if hasattr(self.longrepr, "reprtraceback") and hasattr(
227 print(f"DEBUG: has chain: {hasattr(self.longrepr, 'chain')}")
228 print(f"DEBUG: has reprtraceback: {hasattr(self.longrepr, 'reprtraceback')} and reprcrash: {hasattr(self.longrepr, 'reprcrash')}")
229 if hasattr(self.longrepr, "chain"):
230 # Handle ExceptionChainRepr (chained exceptions)
231 print("DEBUG: Calling disassembled_report for ExceptionChainRepr")
232 d["longrepr"] = disassembled_report(self)
233 elif hasattr(self.longrepr, "reprtraceback") and hasattr(
190234 self.longrepr, "reprcrash"
191235 ):
236 # Handle regular ReprExceptionInfo
237 print("DEBUG: Calling disassembled_report for ReprExceptionInfo")
192238 d["longrepr"] = disassembled_report(self)
193239 else:
240 print("DEBUG: Converting to string")
194241 d["longrepr"] = str(self.longrepr)
195242 else:
243 print("DEBUG: Not calling disassembled_report")
196244 d["longrepr"] = self.longrepr
197245 for name in d:
198246 if isinstance(d[name], (py.path.local, Path)):
212260 Experimental method.
213261 """
214262 if reportdict["longrepr"]:
215 if (
263 if "repr_type" in reportdict["longrepr"]:
264 # Handle new serialization format with repr_type
265 repr_type = reportdict["longrepr"]["repr_type"]
266 sections = reportdict["longrepr"]["sections"]
267
268 if repr_type == "ExceptionChainRepr":
269 # Handle ExceptionChainRepr
270 chain_data = reportdict["longrepr"]["chain"]
271 chain = []
272
273 for element_data in chain_data:
274 # Deserialize reprtraceback
275 reprtraceback_data = element_data["reprtraceback"]
276 unserialized_entries = []
277 for entry_data in reprtraceback_data["reprentries"]:
278 data = entry_data["data"]
279 entry_type = entry_data["type"]
280 if entry_type == "ReprEntry":
281 reprfuncargs = None
282 reprfileloc = None
283 reprlocals = None
284 if data["reprfuncargs"]:
285 reprfuncargs = ReprFuncArgs(**data["reprfuncargs"])
286 if data["reprfileloc"]:
287 reprfileloc = ReprFileLocation(**data["reprfileloc"])
288 if data["reprlocals"]:
289 reprlocals = ReprLocals(data["reprlocals"]["lines"])
290
291 reprentry = ReprEntry(
292 lines=data["lines"],
293 reprfuncargs=reprfuncargs,
294 reprlocals=reprlocals,
295 filelocrepr=reprfileloc,
296 style=data["style"],
297 )
298 elif entry_type == "ReprEntryNative":
299 reprentry = ReprEntryNative(data["lines"])
300 else:
301 _report_unserialization_failure(entry_type, cls, reportdict)
302 unserialized_entries.append(reprentry)
303 reprtraceback_data["reprentries"] = unserialized_entries
304
305 # Deserialize reprcrash
306 reprcrash_data = element_data["reprcrash"]
307 reprcrash = ReprFileLocation(**reprcrash_data) if reprcrash_data else None
308
309 # Get descr
310 descr = element_data["descr"]
311
312 chain.append((ReprTraceback(**reprtraceback_data), reprcrash, descr))
313
314 exception_info = ExceptionChainRepr(chain)
315 for section in sections:
316 exception_info.addsection(*section)
317 reportdict["longrepr"] = exception_info
318 elif repr_type == "ReprExceptionInfo":
319 # Handle regular ReprExceptionInfo
320 reprtraceback = reportdict["longrepr"]["reprtraceback"]
321 reprcrash = reportdict["longrepr"]["reprcrash"]
322
323 unserialized_entries = []
324 reprentry = None
325 for entry_data in reprtraceback["reprentries"]:
326 data = entry_data["data"]
327 entry_type = entry_data["type"]
328 if entry_type == "ReprEntry":
329 reprfuncargs = None
330 reprfileloc = None
331 reprlocals = None
332 if data["reprfuncargs"]:
333 reprfuncargs = ReprFuncArgs(**data["reprfuncargs"])
334 if data["reprfileloc"]:
335 reprfileloc = ReprFileLocation(**data["reprfileloc"])
336 if data["reprlocals"]:
337 reprlocals = ReprLocals(data["reprlocals"]["lines"])
338
339 reprentry = ReprEntry(
340 lines=data["lines"],
341 reprfuncargs=reprfuncargs,
342 reprlocals=reprlocals,
343 filelocrepr=reprfileloc,
344 style=data["style"],
345 )
346 elif entry_type == "ReprEntryNative":
347 reprentry = ReprEntryNative(data["lines"])
348 else:
349 _report_unserialization_failure(entry_type, cls, reportdict)
350 unserialized_entries.append(reprentry)
351 reprtraceback["reprentries"] = unserialized_entries
352
353 exception_info = ReprExceptionInfo(
354 reprtraceback=ReprTraceback(**reprtraceback),
355 reprcrash=ReprFileLocation(**reprcrash),
356 )
357
358 for section in sections:
359 exception_info.addsection(*section)
360 reportdict["longrepr"] = exception_info
361 elif (
216362 "reprcrash" in reportdict["longrepr"]
217363 and "reprtraceback" in reportdict["longrepr"]
218364 ):
219
365 # Handle old serialization format for backward compatibility
220366 reprtraceback = reportdict["longrepr"]["reprtraceback"]
221367 reprcrash = reportdict["longrepr"]["reprcrash"]
222368
Test NameStatus
testing/test_reports.py::TestReportSerialization::test_xdist_longrepr_to_str_issue_241
Fail
testing/test_reports.py::TestReportSerialization::test_deserialization_failure
Fail
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_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::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.