| 4 | 4 | import py |
| 5 | 5 | |
| 6 | 6 | from _pytest._code.code import ExceptionInfo |
| 7 | from _pytest._code.code import ExceptionChainRepr | |
| 7 | 8 | from _pytest._code.code import ReprEntry |
| 8 | 9 | from _pytest._code.code import ReprEntryNative |
| 9 | 10 | from _pytest._code.code import ReprExceptionInfo |
| 151 | 152 | ) |
| 152 | 153 | return verbose |
| 153 | 154 | |
| 154 | def _to_json(self): | |
| 155 | """ | |
| 156 | This was originally the serialize_report() function from xdist (ca03269). | |
| 157 | ||
| 158 | Returns the contents of this report as a dict of builtin entries, suitable for | |
| 159 | serialization. | |
| 160 | ||
| 161 | Experimental method. | |
| 162 | """ | |
| 155 | def _serialize_repr_traceback(reprtraceback): | |
| 156 | reprtraceback_data = reprtraceback.__dict__.copy() | |
| 157 | new_entries = [] | |
| 158 | for entry in reprtraceback_data["reprentries"]: | |
| 159 | entry_data = { | |
| 160 | "type": type(entry).__name__, | |
| 161 | "data": entry.__dict__.copy(), | |
| 162 | } | |
| 163 | for key, value in entry_data["data"].items(): | |
| 164 | if hasattr(value, "__dict__"): | |
| 165 | entry_data["data"][key] = value.__dict__.copy() | |
| 166 | new_entries.append(entry_data) | |
| 167 | reprtraceback_data["reprentries"] = new_entries | |
| 168 | return reprtraceback_data | |
| 169 | ||
| 170 | def _serialize_repr_crash(reprcrash): | |
| 171 | return reprcrash.__dict__.copy() | |
| 172 | ||
| 173 | def _deserialize_repr_traceback(reprtraceback_data): | |
| 174 | unserialized_entries = [] | |
| 175 | reprentry = None | |
| 176 | for entry_data in reprtraceback_data["reprentries"]: | |
| 177 | data = entry_data["data"] | |
| 178 | entry_type = entry_data["type"] | |
| 179 | if entry_type == "ReprEntry": | |
| 180 | reprfuncargs = None | |
| 181 | reprfileloc = None | |
| 182 | reprlocals = None | |
| 183 | if data["reprfuncargs"]: | |
| 184 | reprfuncargs = ReprFuncArgs(**data["reprfuncargs"]) | |
| 185 | if data["reprfileloc"]: | |
| 186 | reprfileloc = ReprFileLocation(**data["reprfileloc"]) | |
| 187 | if data["reprlocals"]: | |
| 188 | reprlocals = ReprLocals(data["reprlocals"]["lines"]) | |
| 189 | ||
| 190 | reprentry = ReprEntry( | |
| 191 | lines=data["lines"], | |
| 192 | reprfuncargs=reprfuncargs, | |
| 193 | reprlocals=reprlocals, | |
| 194 | filelocrepr=reprfileloc, | |
| 195 | style=data["style"], | |
| 196 | ) | |
| 197 | elif entry_type == "ReprEntryNative": | |
| 198 | reprentry = ReprEntryNative(data["lines"]) | |
| 199 | else: | |
| 200 | _report_unserialization_failure(entry_type, cls, reportdict) | |
| 201 | unserialized_entries.append(reprentry) | |
| 202 | reprtraceback_data["reprentries"] = unserialized_entries | |
| 203 | return ReprTraceback(**reprtraceback_data) | |
| 204 | ||
| 205 | def _deserialize_repr_crash(reprcrash_data): | |
| 206 | return ReprFileLocation(**reprcrash_data) | |
| 163 | 207 | |
| 208 | def _to_json(self): | |
| 164 | 209 | def disassembled_report(rep): |
| 165 | reprtraceback = rep.longrepr.reprtraceback.__dict__.copy() | |
| 166 | reprcrash = rep.longrepr.reprcrash.__dict__.copy() | |
| 167 | ||
| 210 | # Check if we have an ExceptionChainRepr | |
| 211 | if hasattr(rep.longrepr, 'chain'): | |
| 212 | # Handle ExceptionChainRepr - serialize the entire chain | |
| 213 | chain = [] | |
| 214 | for reprtraceback, reprcrash, description in rep.longrepr.chain: | |
| 215 | chain.append(( | |
| 216 | _serialize_repr_traceback(reprtraceback), | |
| 217 | _serialize_repr_crash(reprcrash), | |
| 218 | description | |
| 219 | )) | |
| 220 | ||
| 221 | return { | |
| 222 | "chain": chain, | |
| 223 | "type": "ExceptionChainRepr", | |
| 224 | "sections": rep.longrepr.sections, | |
| 225 | } | |
| 226 | else: | |
| 227 | # Handle regular ReprExceptionInfo | |
| 228 | reprtraceback = _serialize_repr_traceback(rep.longrepr.reprtraceback) | |
| 229 | reprcrash = _serialize_repr_crash(rep.longrepr.reprcrash) | |
| 230 | ||
| 231 | return { | |
| 232 | "reprcrash": reprcrash, | |
| 233 | "reprtraceback": reprtraceback, | |
| 234 | "sections": rep.longrepr.sections, | |
| 235 | } | |
| 236 | ||
| 237 | def _serialize_repr_traceback(reprtraceback): | |
| 238 | reprtraceback_data = reprtraceback.__dict__.copy() | |
| 168 | 239 | new_entries = [] |
| 169 | for entry in reprtraceback["reprentries"]: | |
| 240 | for entry in reprtraceback_data["reprentries"]: | |
| 170 | 241 | entry_data = { |
| 171 | 242 | "type": type(entry).__name__, |
| 172 | 243 | "data": entry.__dict__.copy(), |
| 175 | 246 | if hasattr(value, "__dict__"): |
| 176 | 247 | entry_data["data"][key] = value.__dict__.copy() |
| 177 | 248 | 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 | } | |
| 249 | reprtraceback_data["reprentries"] = new_entries | |
| 250 | return reprtraceback_data | |
| 251 | ||
| 252 | def _serialize_repr_crash(reprcrash): | |
| 253 | return reprcrash.__dict__.copy() | |
| 254 | ||
| 255 | def _deserialize_repr_traceback(reprtraceback_data): | |
| 256 | unserialized_entries = [] | |
| 257 | reprentry = None | |
| 258 | for entry_data in reprtraceback_data["reprentries"]: | |
| 259 | data = entry_data["data"] | |
| 260 | entry_type = entry_data["type"] | |
| 261 | if entry_type == "ReprEntry": | |
| 262 | reprfuncargs = None | |
| 263 | reprfileloc = None | |
| 264 | reprlocals = None | |
| 265 | if data["reprfuncargs"]: | |
| 266 | reprfuncargs = ReprFuncArgs(**data["reprfuncargs"]) | |
| 267 | if data["reprfileloc"]: | |
| 268 | reprfileloc = ReprFileLocation(**data["reprfileloc"]) | |
| 269 | if data["reprlocals"]: | |
| 270 | reprlocals = ReprLocals(data["reprlocals"]["lines"]) | |
| 271 | ||
| 272 | reprentry = ReprEntry( | |
| 273 | lines=data["lines"], | |
| 274 | reprfuncargs=reprfuncargs, | |
| 275 | reprlocals=reprlocals, | |
| 276 | filelocrepr=reprfileloc, | |
| 277 | style=data["style"], | |
| 278 | ) | |
| 279 | elif entry_type == "ReprEntryNative": | |
| 280 | reprentry = ReprEntryNative(data["lines"]) | |
| 281 | else: | |
| 282 | _report_unserialization_failure(entry_type, cls, reportdict) | |
| 283 | unserialized_entries.append(reprentry) | |
| 284 | reprtraceback_data["reprentries"] = unserialized_entries | |
| 285 | return ReprTraceback(**reprtraceback_data) | |
| 286 | ||
| 287 | def _deserialize_repr_crash(reprcrash_data): | |
| 288 | return ReprFileLocation(**reprcrash_data) | |
| 186 | 289 | |
| 187 | 290 | d = self.__dict__.copy() |
| 188 | 291 | if hasattr(self.longrepr, "toterminal"): |
| 212 | 315 | Experimental method. |
| 213 | 316 | """ |
| 214 | 317 | if reportdict["longrepr"]: |
| 215 | if ( | |
| 318 | if "chain" in reportdict["longrepr"]: | |
| 319 | # Handle ExceptionChainRepr | |
| 320 | chain = [] | |
| 321 | for reprtraceback_data, reprcrash_data, description in reportdict["longrepr"]["chain"]: | |
| 322 | reprtraceback = _deserialize_repr_traceback(reprtraceback_data) | |
| 323 | reprcrash = _deserialize_repr_crash(reprcrash_data) | |
| 324 | chain.append((reprtraceback, reprcrash, description)) | |
| 325 | ||
| 326 | exception_info = ExceptionChainRepr(chain) | |
| 327 | ||
| 328 | for section in reportdict["longrepr"]["sections"]: | |
| 329 | exception_info.addsection(*section) | |
| 330 | reportdict["longrepr"] = exception_info | |
| 331 | elif ( | |
| 216 | 332 | "reprcrash" in reportdict["longrepr"] |
| 217 | 333 | and "reprtraceback" in reportdict["longrepr"] |
| 218 | 334 | ): |
| Test Name | Status |
|---|---|
testing/test_reports.py::TestReportSerialization::test_chained_exceptions[TestReport] | Fail |
testing/test_reports.py::TestReportSerialization::test_chained_exceptions[CollectReport] | Fail |
testing/test_reports.py::TestReportSerialization::test_xdist_longrepr_to_str_issue_241 | Fail |
testing/test_reports.py::TestReportSerialization::test_xdist_report_longrepr_reprcrash_130 | Fail |
testing/test_reports.py::TestReportSerialization::test_reprentries_serialization_170 | Fail |
testing/test_reports.py::TestReportSerialization::test_itemreport_outcomes | Fail |
testing/test_reports.py::TestReportSerialization::test_deserialization_failure | Fail |
testing/test_reports.py::TestHooks::test_test_report | Fail |
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_reprentries_serialization_196 | 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_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.