api

Finished
1212from _pytest._code.code import ReprLocals
1313from _pytest._code.code import ReprTraceback
1414from _pytest._code.code import TerminalRepr
15from _pytest._code.code import ExceptionChainRepr
1516from _pytest.outcomes import skip
1617from _pytest.pathlib import Path
1718
184185 "sections": rep.longrepr.sections,
185186 }
186187
188 def disassembled_chain_report(rep):
189 """Serialize ExceptionChainRepr objects preserving the chain."""
190 chain_data = []
191 for reprtraceback, reprcrash, descr in rep.longrepr.chain:
192 # Serialize each element in the chain
193 reprtraceback_dict = reprtraceback.__dict__.copy()
194 reprcrash_dict = reprcrash.__dict__.copy() if reprcrash else None
195
196 new_entries = []
197 for entry in reprtraceback_dict["reprentries"]:
198 entry_data = {
199 "type": type(entry).__name__,
200 "data": entry.__dict__.copy(),
201 }
202 for key, value in entry_data["data"].items():
203 if hasattr(value, "__dict__"):
204 entry_data["data"][key] = value.__dict__.copy()
205 new_entries.append(entry_data)
206
207 reprtraceback_dict["reprentries"] = new_entries
208
209 chain_data.append({
210 "reprtraceback": reprtraceback_dict,
211 "reprcrash": reprcrash_dict,
212 "description": descr,
213 })
214
215 return {
216 "chain": chain_data,
217 "sections": rep.longrepr.sections,
218 "repr_chain": True, # Marker to identify this as a chain report
219 }
220
221 def disassembled_chain_report(rep):
222 """Serialize ExceptionChainRepr objects preserving the chain."""
223 chain_data = []
224 for reprtraceback, reprcrash, descr in rep.longrepr.chain:
225 # Serialize each element in the chain
226 reprtraceback_dict = reprtraceback.__dict__.copy()
227 reprcrash_dict = reprcrash.__dict__.copy() if reprcrash else None
228
229 new_entries = []
230 for entry in reprtraceback_dict["reprentries"]:
231 entry_data = {
232 "type": type(entry).__name__,
233 "data": entry.__dict__.copy(),
234 }
235 for key, value in entry_data["data"].items():
236 if hasattr(value, "__dict__"):
237 entry_data["data"][key] = value.__dict__.copy()
238 new_entries.append(entry_data)
239
240 reprtraceback_dict["reprentries"] = new_entries
241
242 chain_data.append({
243 "reprtraceback": reprtraceback_dict,
244 "reprcrash": reprcrash_dict,
245 "description": descr,
246 })
247
248 return {
249 "chain": chain_data,
250 "sections": rep.longrepr.sections,
251 "repr_chain": True, # Marker to identify this as a chain report
252 }
253
187254 d = self.__dict__.copy()
255 print(f"DEBUG: longrepr type: {type(self.longrepr)}")
256 print(f"DEBUG: has toterminal: {hasattr(self.longrepr, 'toterminal')}")
188257 if hasattr(self.longrepr, "toterminal"):
258 print(f"DEBUG: has reprtraceback: {hasattr(self.longrepr, 'reprtraceback')}")
259 print(f"DEBUG: has reprcrash: {hasattr(self.longrepr, 'reprcrash')}")
189260 if hasattr(self.longrepr, "reprtraceback") and hasattr(
190261 self.longrepr, "reprcrash"
191262 ):
192 d["longrepr"] = disassembled_report(self)
263 # Check if this is an ExceptionChainRepr
264 print(f"DEBUG: has chain: {hasattr(self.longrepr, 'chain')}")
265 if hasattr(self.longrepr, "chain"):
266 print("DEBUG: Using disassembled_chain_report")
267 d["longrepr"] = disassembled_chain_report(self)
268 else:
269 print("DEBUG: Using disassembled_report")
270 d["longrepr"] = disassembled_report(self)
193271 else:
272 print("DEBUG: Using str conversion")
194273 d["longrepr"] = str(self.longrepr)
195274 else:
275 print("DEBUG: No toterminal, using direct assignment")
196276 d["longrepr"] = self.longrepr
197277 for name in d:
198278 if isinstance(d[name], (py.path.local, Path)):
212292 Experimental method.
213293 """
214294 if reportdict["longrepr"]:
215 if (
295 # Check if this is a chain report
296 if reportdict["longrepr"].get("repr_chain"):
297 # Deserialize ExceptionChainRepr
298 chain_data = reportdict["longrepr"]["chain"]
299 unserialized_chain = []
300
301 for chain_element in chain_data:
302 reprtraceback_dict = chain_element["reprtraceback"]
303 reprcrash_dict = chain_element["reprcrash"]
304 descr = chain_element["description"]
305
306 # Reconstruct reprtraceback entries
307 unserialized_entries = []
308 for entry_data in reprtraceback_dict["reprentries"]:
309 data = entry_data["data"]
310 entry_type = entry_data["type"]
311 if entry_type == "ReprEntry":
312 reprfuncargs = None
313 reprfileloc = None
314 reprlocals = None
315 if data["reprfuncargs"]:
316 reprfuncargs = ReprFuncArgs(**data["reprfuncargs"])
317 if data["reprfileloc"]:
318 reprfileloc = ReprFileLocation(**data["reprfileloc"])
319 if data["reprlocals"]:
320 reprlocals = ReprLocals(data["reprlocals"]["lines"])
321
322 reprentry = ReprEntry(
323 lines=data["lines"],
324 reprfuncargs=reprfuncargs,
325 reprlocals=reprlocals,
326 filelocrepr=reprfileloc,
327 style=data["style"],
328 )
329 elif entry_type == "ReprEntryNative":
330 reprentry = ReprEntryNative(data["lines"])
331 else:
332 _report_unserialization_failure(entry_type, cls, reportdict)
333 unserialized_entries.append(reprentry)
334
335 reprtraceback_dict["reprentries"] = unserialized_entries
336
337 # Reconstruct objects
338 reconstructed_reprtraceback = ReprTraceback(**reprtraceback_dict)
339 reconstructed_reprcrash = ReprFileLocation(**reprcrash_dict) if reprcrash_dict else None
340
341 unserialized_chain.append((reconstructed_reprtraceback, reconstructed_reprcrash, descr))
342
343 # Create ExceptionChainRepr
344 exception_chain_repr = ExceptionChainRepr(unserialized_chain)
345
346 for section in reportdict["longrepr"]["sections"]:
347 exception_chain_repr.addsection(*section)
348 reportdict["longrepr"] = exception_chain_repr
349
350 elif (
216351 "reprcrash" in reportdict["longrepr"]
217352 and "reprtraceback" in reportdict["longrepr"]
218353 ):
Test NameStatus
testing/test_reports.py::TestReportSerialization::test_xdist_longrepr_to_str_issue_241
Fail
testing/test_reports.py::TestReportSerialization::test_itemreport_outcomes
Fail
testing/test_reports.py::TestReportSerialization::test_collectreport_fail
Fail
testing/test_reports.py::TestReportSerialization::test_extended_report_deserialization
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_collectreport_passed
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.