| 3 | 3 | |
| 4 | 4 | import py |
| 5 | 5 | |
| 6 | from _pytest._code.code import ExceptionChainRepr | |
| 6 | 7 | from _pytest._code.code import ExceptionInfo |
| 7 | 8 | from _pytest._code.code import ReprEntry |
| 8 | 9 | from _pytest._code.code import ReprEntryNative |
| 162 | 163 | """ |
| 163 | 164 | |
| 164 | 165 | 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 | # Check if this is an ExceptionChainRepr with a chain attribute | |
| 167 | if hasattr(rep.longrepr, 'chain'): | |
| 168 | # Serialize the chain attribute | |
| 169 | chain = [] | |
| 170 | for reprtraceback, reprcrash, description in rep.longrepr.chain: | |
| 171 | # Serialize each element in the chain | |
| 172 | serialized_traceback = reprtraceback.__dict__.copy() | |
| 173 | new_entries = [] | |
| 174 | for entry in serialized_traceback["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 | serialized_traceback["reprentries"] = new_entries | |
| 184 | ||
| 185 | serialized_crash = reprcrash.__dict__.copy() if reprcrash else None | |
| 186 | chain.append((serialized_traceback, serialized_crash, description)) | |
| 187 | ||
| 188 | # Use the last element's traceback and crash for backward compatibility | |
| 189 | last_traceback, last_crash, _ = rep.longrepr.chain[-1] | |
| 190 | reprtraceback = last_traceback.__dict__.copy() | |
| 191 | reprcrash = last_crash.__dict__.copy() if last_crash else None | |
| 192 | ||
| 193 | # Re-serialize the last traceback entries | |
| 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 | reprtraceback["reprentries"] = new_entries | |
| 205 | ||
| 206 | return { | |
| 207 | "reprcrash": reprcrash, | |
| 208 | "reprtraceback": reprtraceback, | |
| 209 | "sections": rep.longrepr.sections, | |
| 210 | "chain": chain, | |
| 211 | } | |
| 212 | else: | |
| 213 | # Original logic for ReprExceptionInfo | |
| 214 | reprtraceback = rep.longrepr.reprtraceback.__dict__.copy() | |
| 215 | reprcrash = rep.longrepr.reprcrash.__dict__.copy() | |
| 216 | ||
| 217 | new_entries = [] | |
| 218 | for entry in reprtraceback["reprentries"]: | |
| 219 | entry_data = { | |
| 220 | "type": type(entry).__name__, | |
| 221 | "data": entry.__dict__.copy(), | |
| 222 | } | |
| 223 | for key, value in entry_data["data"].items(): | |
| 224 | if hasattr(value, "__dict__"): | |
| 225 | entry_data["data"][key] = value.__dict__.copy() | |
| 226 | new_entries.append(entry_data) | |
| 227 | ||
| 228 | reprtraceback["reprentries"] = new_entries | |
| 229 | ||
| 230 | return { | |
| 231 | "reprcrash": reprcrash, | |
| 232 | "reprtraceback": reprtraceback, | |
| 233 | "sections": rep.longrepr.sections, | |
| 173 | 234 | } |
| 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 | } | |
| 186 | 235 | |
| 187 | 236 | d = self.__dict__.copy() |
| 188 | 237 | if hasattr(self.longrepr, "toterminal"): |
| 250 | 299 | unserialized_entries.append(reprentry) |
| 251 | 300 | reprtraceback["reprentries"] = unserialized_entries |
| 252 | 301 | |
| 253 | exception_info = ReprExceptionInfo( | |
| 254 | reprtraceback=ReprTraceback(**reprtraceback), | |
| 255 | reprcrash=ReprFileLocation(**reprcrash), | |
| 256 | ) | |
| 302 | # Check if this is an ExceptionChainRepr with a chain attribute | |
| 303 | if "chain" in reportdict["longrepr"]: | |
| 304 | # Deserialize the chain attribute | |
| 305 | chain = [] | |
| 306 | for serialized_traceback, serialized_crash, description in reportdict["longrepr"]["chain"]: | |
| 307 | # Deserialize each traceback in the chain | |
| 308 | unserialized_entries = [] | |
| 309 | for entry_data in serialized_traceback["reprentries"]: | |
| 310 | data = entry_data["data"] | |
| 311 | entry_type = entry_data["type"] | |
| 312 | if entry_type == "ReprEntry": | |
| 313 | reprfuncargs = None | |
| 314 | reprfileloc = None | |
| 315 | reprlocals = None | |
| 316 | if data["reprfuncargs"]: | |
| 317 | reprfuncargs = ReprFuncArgs(**data["reprfuncargs"]) # type: ignore | |
| 318 | if data["reprfileloc"]: | |
| 319 | reprfileloc = ReprFileLocation(**data["reprfileloc"]) # type: ignore | |
| 320 | if data["reprlocals"]: | |
| 321 | reprlocals = ReprLocals(data["reprlocals"]["lines"]) # type: ignore | |
| 322 | ||
| 323 | reprentry = ReprEntry( | |
| 324 | lines=data["lines"], | |
| 325 | reprfuncargs=reprfuncargs, | |
| 326 | reprlocals=reprlocals, | |
| 327 | filelocrepr=reprfileloc, | |
| 328 | style=data["style"], | |
| 329 | ) | |
| 330 | elif entry_type == "ReprEntryNative": | |
| 331 | reprentry = ReprEntryNative(data["lines"]) # type: ignore | |
| 332 | else: | |
| 333 | _report_unserialization_failure(entry_type, cls, reportdict) | |
| 334 | unserialized_entries.append(reprentry) | |
| 335 | serialized_traceback["reprentries"] = unserialized_entries | |
| 336 | ||
| 337 | traceback_obj = ReprTraceback(**serialized_traceback) | |
| 338 | crash_obj = ReprFileLocation(**serialized_crash) if serialized_crash else None | |
| 339 | chain.append((traceback_obj, crash_obj, description)) | |
| 340 | ||
| 341 | exception_info = ExceptionChainRepr(chain) | |
| 342 | else: | |
| 343 | # Original logic for ReprExceptionInfo | |
| 344 | exception_info = ReprExceptionInfo( | |
| 345 | reprtraceback=ReprTraceback(**reprtraceback), | |
| 346 | reprcrash=ReprFileLocation(**reprcrash), | |
| 347 | ) | |
| 257 | 348 | |
| 258 | 349 | for section in reportdict["longrepr"]["sections"]: |
| 259 | 350 | exception_info.addsection(*section) |
| Test Name | Status |
|---|---|
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.