| 9 | 9 | from _pytest._code.code import ReprExceptionInfo |
| 10 | 10 | from _pytest._code.code import ReprFileLocation |
| 11 | 11 | from _pytest._code.code import ReprFuncArgs |
| 12 | from _pytest._code.code import ExceptionChainRepr | |
| 12 | 13 | from _pytest._code.code import ReprLocals |
| 13 | 14 | from _pytest._code.code import ReprTraceback |
| 14 | 15 | from _pytest._code.code import TerminalRepr |
| 184 | 185 | "sections": rep.longrepr.sections, |
| 185 | 186 | } |
| 186 | 187 | |
| 188 | def serialize_repr_entry(entry): | |
| 189 | entry_data = { | |
| 190 | "type": type(entry).__name__, | |
| 191 | "data": entry.__dict__.copy(), | |
| 192 | } | |
| 193 | for key, value in entry_data["data"].items(): | |
| 194 | if hasattr(value, "__dict__"): | |
| 195 | entry_data["data"][key] = value.__dict__.copy() | |
| 196 | return entry_data | |
| 197 | ||
| 198 | def serialize_repr_traceback(reprtraceback): | |
| 199 | result = reprtraceback.__dict__.copy() | |
| 200 | result["reprentries"] = [ | |
| 201 | serialize_repr_entry(entry) for entry in result["reprentries"] | |
| 202 | ] | |
| 203 | return result | |
| 204 | ||
| 205 | def serialize_repr_file_location(reprfileloc): | |
| 206 | if reprfileloc is None: | |
| 207 | return None | |
| 208 | return reprfileloc.__dict__.copy() | |
| 209 | ||
| 210 | def serialize_exception_chain(chain): | |
| 211 | result = [] | |
| 212 | for reprtraceback, reprcrash, description in chain: | |
| 213 | result.append( | |
| 214 | ( | |
| 215 | serialize_repr_traceback(reprtraceback), | |
| 216 | serialize_repr_file_location(reprcrash), | |
| 217 | description, | |
| 218 | ) | |
| 219 | ) | |
| 220 | return result | |
| 221 | ||
| 187 | 222 | d = self.__dict__.copy() |
| 188 | 223 | if hasattr(self.longrepr, "toterminal"): |
| 189 | if hasattr(self.longrepr, "reprtraceback") and hasattr( | |
| 224 | if isinstance(self.longrepr, ExceptionChainRepr): | |
| 225 | # Handle ExceptionChainRepr objects | |
| 226 | d["longrepr"] = { | |
| 227 | "type": "ExceptionChainRepr", | |
| 228 | "chain": serialize_exception_chain(self.longrepr.chain), | |
| 229 | "sections": self.longrepr.sections, | |
| 230 | } | |
| 231 | elif hasattr(self.longrepr, "reprtraceback") and hasattr( | |
| 190 | 232 | self.longrepr, "reprcrash" |
| 191 | 233 | ): |
| 192 | 234 | d["longrepr"] = disassembled_report(self) |
| 201 | 243 | d[name] = None # for now |
| 202 | 244 | return d |
| 203 | 245 | |
| 246 | @classmethod | |
| 247 | def _deserialize_exception_chain(cls, chain_data): | |
| 248 | """Deserialize an exception chain from serialized data.""" | |
| 249 | result = [] | |
| 250 | for reprtraceback_data, reprcrash_data, description in chain_data: | |
| 251 | # Reconstruct reprtraceback | |
| 252 | unserialized_entries = [] | |
| 253 | for entry_data in reprtraceback_data["reprentries"]: | |
| 254 | data = entry_data["data"] | |
| 255 | entry_type = entry_data["type"] | |
| 256 | if entry_type == "ReprEntry": | |
| 257 | reprfuncargs = None | |
| 258 | reprfileloc = None | |
| 259 | reprlocals = None | |
| 260 | if data["reprfuncargs"]: | |
| 261 | reprfuncargs = ReprFuncArgs(**data["reprfuncargs"]) | |
| 262 | if data["reprfileloc"]: | |
| 263 | reprfileloc = ReprFileLocation(**data["reprfileloc"]) | |
| 264 | if data["reprlocals"]: | |
| 265 | reprlocals = ReprLocals(data["reprlocals"]["lines"]) | |
| 266 | ||
| 267 | reprentry = ReprEntry( | |
| 268 | lines=data["lines"], | |
| 269 | reprfuncargs=reprfuncargs, | |
| 270 | reprlocals=reprlocals, | |
| 271 | filelocrepr=reprfileloc, | |
| 272 | style=data["style"], | |
| 273 | ) | |
| 274 | elif entry_type == "ReprEntryNative": | |
| 275 | reprentry = ReprEntryNative(data["lines"]) | |
| 276 | else: | |
| 277 | _report_unserialization_failure(entry_type, cls, {}) | |
| 278 | unserialized_entries.append(reprentry) | |
| 279 | ||
| 280 | reprtraceback_data["reprentries"] = unserialized_entries | |
| 281 | reprtraceback = ReprTraceback(**reprtraceback_data) | |
| 282 | ||
| 283 | # Reconstruct reprcrash | |
| 284 | reprcrash = ReprFileLocation(**reprcrash_data) if reprcrash_data else None | |
| 285 | ||
| 286 | result.append((reprtraceback, reprcrash, description)) | |
| 287 | return result | |
| 288 | ||
| 204 | 289 | @classmethod |
| 205 | 290 | def _from_json(cls, reportdict): |
| 206 | 291 | """ |
| 212 | 297 | Experimental method. |
| 213 | 298 | """ |
| 214 | 299 | if reportdict["longrepr"]: |
| 215 | if ( | |
| 300 | if reportdict["longrepr"].get("type") == "ExceptionChainRepr": | |
| 301 | # Handle ExceptionChainRepr objects | |
| 302 | chain = cls._deserialize_exception_chain(reportdict["longrepr"]["chain"]) | |
| 303 | exception_info = ExceptionChainRepr(chain) | |
| 304 | for section in reportdict["longrepr"]["sections"]: | |
| 305 | exception_info.addsection(*section) | |
| 306 | reportdict["longrepr"] = exception_info | |
| 307 | elif ( | |
| 216 | 308 | "reprcrash" in reportdict["longrepr"] |
| 217 | 309 | and "reprtraceback" in reportdict["longrepr"] |
| 218 | 310 | ): |
| Test Name | Status |
|---|---|
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.