Return **kwargs that can be used to construct a TestReport or CollectReport instance. This was originally the serialize_report() function from xdist (ca03269).
(reportdict: dict[str, Any])
| 612 | |
| 613 | |
| 614 | def _report_kwargs_from_json(reportdict: dict[str, Any]) -> dict[str, Any]: |
| 615 | """Return **kwargs that can be used to construct a TestReport or |
| 616 | CollectReport instance. |
| 617 | |
| 618 | This was originally the serialize_report() function from xdist (ca03269). |
| 619 | """ |
| 620 | |
| 621 | def deserialize_repr_entry(entry_data): |
| 622 | data = entry_data["data"] |
| 623 | entry_type = entry_data["type"] |
| 624 | if entry_type == "ReprEntry": |
| 625 | reprfuncargs = None |
| 626 | reprfileloc = None |
| 627 | reprlocals = None |
| 628 | if data["reprfuncargs"]: |
| 629 | reprfuncargs = ReprFuncArgs(**data["reprfuncargs"]) |
| 630 | if data["reprfileloc"]: |
| 631 | reprfileloc = ReprFileLocation(**data["reprfileloc"]) |
| 632 | if data["reprlocals"]: |
| 633 | reprlocals = ReprLocals(data["reprlocals"]["lines"]) |
| 634 | |
| 635 | reprentry: ReprEntry | ReprEntryNative = ReprEntry( |
| 636 | lines=data["lines"], |
| 637 | reprfuncargs=reprfuncargs, |
| 638 | reprlocals=reprlocals, |
| 639 | reprfileloc=reprfileloc, |
| 640 | style=data["style"], |
| 641 | ) |
| 642 | elif entry_type == "ReprEntryNative": |
| 643 | reprentry = ReprEntryNative(data["lines"]) |
| 644 | else: |
| 645 | _report_unserialization_failure(entry_type, TestReport, reportdict) |
| 646 | return reprentry |
| 647 | |
| 648 | def deserialize_repr_traceback(repr_traceback_dict): |
| 649 | repr_traceback_dict["reprentries"] = [ |
| 650 | deserialize_repr_entry(x) for x in repr_traceback_dict["reprentries"] |
| 651 | ] |
| 652 | return ReprTraceback(**repr_traceback_dict) |
| 653 | |
| 654 | def deserialize_repr_crash(repr_crash_dict: dict[str, Any] | None): |
| 655 | if repr_crash_dict is not None: |
| 656 | return ReprFileLocation(**repr_crash_dict) |
| 657 | else: |
| 658 | return None |
| 659 | |
| 660 | if ( |
| 661 | reportdict["longrepr"] |
| 662 | and "reprcrash" in reportdict["longrepr"] |
| 663 | and "reprtraceback" in reportdict["longrepr"] |
| 664 | ): |
| 665 | reprtraceback = deserialize_repr_traceback( |
| 666 | reportdict["longrepr"]["reprtraceback"] |
| 667 | ) |
| 668 | reprcrash = deserialize_repr_crash(reportdict["longrepr"]["reprcrash"]) |
| 669 | if reportdict["longrepr"]["chain"]: |
| 670 | chain = [] |
| 671 | for repr_traceback_data, repr_crash_data, description in reportdict[ |
no test coverage detected