| 184 | 184 | "sections": rep.longrepr.sections, |
| 185 | 185 | } |
| 186 | 186 | |
| 187 | def disassembled_chain_report(rep): | |
| 188 | """Handle ExceptionChainRepr objects by serializing the entire chain.""" | |
| 189 | from _pytest._code.code import ExceptionChainRepr | |
| 190 | ||
| 191 | chain_data = [] | |
| 192 | for element in rep.longrepr.chain: | |
| 193 | reprtraceback, reprcrash, descr = element | |
| 194 | ||
| 195 | # Serialize reprtraceback | |
| 196 | if reprtraceback is not None: | |
| 197 | tb_dict = reprtraceback.__dict__.copy() | |
| 198 | new_entries = [] | |
| 199 | for entry in tb_dict["reprentries"]: | |
| 200 | entry_data = { | |
| 201 | "type": type(entry).__name__, | |
| 202 | "data": entry.__dict__.copy(), | |
| 203 | } | |
| 204 | for key, value in entry_data["data"].items(): | |
| 205 | if hasattr(value, "__dict__"): | |
| 206 | entry_data["data"][key] = value.__dict__.copy() | |
| 207 | new_entries.append(entry_data) | |
| 208 | tb_dict["reprentries"] = new_entries | |
| 209 | else: | |
| 210 | tb_dict = None | |
| 211 | ||
| 212 | # Serialize reprcrash | |
| 213 | if reprcrash is not None: | |
| 214 | crash_dict = reprcrash.__dict__.copy() | |
| 215 | else: | |
| 216 | crash_dict = None | |
| 217 | ||
| 218 | chain_data.append({ | |
| 219 | "reprtraceback": tb_dict, | |
| 220 | "reprcrash": crash_dict, | |
| 221 | "descr": descr, | |
| 222 | }) | |
| 223 | ||
| 224 | return { | |
| 225 | "chain": chain_data, | |
| 226 | "sections": getattr(rep.longrepr, "sections", []), | |
| 227 | "repr_type": "ExceptionChainRepr", | |
| 228 | } | |
| 229 | ||
| 187 | 230 | d = self.__dict__.copy() |
| 188 | 231 | if hasattr(self.longrepr, "toterminal"): |
| 189 | if hasattr(self.longrepr, "reprtraceback") and hasattr( | |
| 232 | # Check if this is an ExceptionChainRepr | |
| 233 | if hasattr(self.longrepr, "chain"): | |
| 234 | d["longrepr"] = disassembled_chain_report(self) | |
| 235 | elif hasattr(self.longrepr, "reprtraceback") and hasattr( | |
| 190 | 236 | self.longrepr, "reprcrash" |
| 191 | 237 | ): |
| 192 | 238 | d["longrepr"] = disassembled_report(self) |
| 212 | 258 | Experimental method. |
| 213 | 259 | """ |
| 214 | 260 | if reportdict["longrepr"]: |
| 261 | # Check if this is an ExceptionChainRepr | |
| 215 | 262 | if ( |
| 263 | "repr_type" in reportdict["longrepr"] | |
| 264 | and reportdict["longrepr"]["repr_type"] == "ExceptionChainRepr" | |
| 265 | ): | |
| 266 | from _pytest._code.code import ExceptionChainRepr | |
| 267 | from _pytest._code.code import ReprTraceback | |
| 268 | from _pytest._code.code import ReprFileLocation | |
| 269 | ||
| 270 | chain_data = reportdict["longrepr"]["chain"] | |
| 271 | chain = [] | |
| 272 | ||
| 273 | for element_data in chain_data: | |
| 274 | # Deserialize reprtraceback | |
| 275 | if element_data["reprtraceback"] is not None: | |
| 276 | reprtraceback = element_data["reprtraceback"] | |
| 277 | unserialized_entries = [] | |
| 278 | reprentry = None | |
| 279 | for entry_data in reprtraceback["reprentries"]: | |
| 280 | data = entry_data["data"] | |
| 281 | entry_type = entry_data["type"] | |
| 282 | if entry_type == "ReprEntry": | |
| 283 | reprfuncargs = None | |
| 284 | reprfileloc = None | |
| 285 | reprlocals = None | |
| 286 | if data["reprfuncargs"]: | |
| 287 | reprfuncargs = ReprFuncArgs(**data["reprfuncargs"]) | |
| 288 | if data["reprfileloc"]: | |
| 289 | reprfileloc = ReprFileLocation(**data["reprfileloc"]) | |
| 290 | if data["reprlocals"]: | |
| 291 | reprlocals = ReprLocals(data["reprlocals"]["lines"]) | |
| 292 | ||
| 293 | reprentry = ReprEntry( | |
| 294 | lines=data["lines"], | |
| 295 | reprfuncargs=reprfuncargs, | |
| 296 | reprlocals=reprlocals, | |
| 297 | filelocrepr=reprfileloc, | |
| 298 | style=data["style"], | |
| 299 | ) | |
| 300 | elif entry_type == "ReprEntryNative": | |
| 301 | reprentry = ReprEntryNative(data["lines"]) | |
| 302 | else: | |
| 303 | _report_unserialization_failure(entry_type, cls, reportdict) | |
| 304 | unserialized_entries.append(reprentry) | |
| 305 | reprtraceback["reprentries"] = unserialized_entries | |
| 306 | reprtraceback_obj = ReprTraceback(**reprtraceback) | |
| 307 | else: | |
| 308 | reprtraceback_obj = None | |
| 309 | ||
| 310 | # Deserialize reprcrash | |
| 311 | if element_data["reprcrash"] is not None: | |
| 312 | reprcrash_obj = ReprFileLocation(**element_data["reprcrash"]) | |
| 313 | else: | |
| 314 | reprcrash_obj = None | |
| 315 | ||
| 316 | chain.append((reprtraceback_obj, reprcrash_obj, element_data["descr"])) | |
| 317 | ||
| 318 | exception_info = ExceptionChainRepr(chain) | |
| 319 | ||
| 320 | # Add sections if they exist | |
| 321 | for section in reportdict["longrepr"].get("sections", []): | |
| 322 | exception_info.addsection(*section) | |
| 323 | reportdict["longrepr"] = exception_info | |
| 324 | elif ( | |
| 216 | 325 | "reprcrash" in reportdict["longrepr"] |
| 217 | 326 | and "reprtraceback" in reportdict["longrepr"] |
| 218 | 327 | ): |
| Test Name | Status |
|---|---|
testing/test_reports.py::TestReportSerialization::test_xdist_longrepr_to_str_issue_241 | Fail |
testing/test_reports.py::TestReportSerialization::test_reprentries_serialization_196 | 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_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.