docstr: This was originally the serialize_report() function from xdist (ca03269).
  
  Factory method that returns either a TestReport or CollectReport, depending on the calling
  class. It's the callers responsibility to know which class to pass here.
  
  Experimental method.
docstr_tok: ["This","was","originally","the","serialize_report","(",")","function","from","xdist","(","ca03269",")",".","Factory","method","that","returns","either","a","TestReport","or","CollectReport",",","depending","on","the","calling","class",".","It","'s","the","callers","responsibility","to","know","which","class","to","pass","here",".","Experimental","method","."]
code: def _from_json(cls, reportdict):
      """
      This was originally the serialize_report() function from xdist (ca03269).
  
      Factory method that returns either a TestReport or CollectReport, depending on the calling
      class. It's the callers responsibility to know which class to pass here.
  
      Experimental method.
      """
      if reportdict["longrepr"]:
          if (
              "reprcrash" in reportdict["longrepr"]
              and "reprtraceback" in reportdict["longrepr"]
          ):
              reprtraceback = reportdict["longrepr"]["reprtraceback"]
              reprcrash = reportdict["longrepr"]["reprcrash"]
  
              unserialized_entries = []
              reprentry = None
              for entry_data in reprtraceback["reprentries"]:
                  data = entry_data["data"]
                  entry_type = entry_data["type"]
                  if entry_type == "ReprEntry":
                      reprfuncargs = None
                      reprfileloc = None
                      reprlocals = None
                      if data["reprfuncargs"]:
                          reprfuncargs = ReprFuncArgs(
                              **data["reprfuncargs"]
                          )
                      if data["reprfileloc"]:
                          reprfileloc = ReprFileLocation(
                              **data["reprfileloc"]
                          )
                      if data["reprlocals"]:
                          reprlocals = ReprLocals(
                              data["reprlocals"]["lines"]
                          )
  
                      reprentry = ReprEntry(
                          lines=data["lines"],
                          reprfuncargs=reprfuncargs,
                          reprlocals=reprlocals,
                          filelocrepr=reprfileloc,
                          style=data["style"],
                      )
                  elif entry_type == "ReprEntryNative":
                      reprentry = ReprEntryNative(data["lines"])
                  else:
                      _report_unserialization_failure(
                          entry_type, cls, reportdict
                      )
                  unserialized_entries.append(reprentry)
              reprtraceback["reprentries"] = unserialized_entries
  
              exception_info = ReprExceptionInfo(
                  reprtraceback=ReprTraceback(**reprtraceback),
                  reprcrash=ReprFileLocation(**reprcrash),
              )
  
              for section in reportdict["longrepr"]["sections"]:
                  exception_info.addsection(*section)
              reportdict["longrepr"] = exception_info
  
      return cls(**reportdict)
  
imports: from pprint import pprint
  import py
  import six
  from _pytest._code.code import ExceptionInfo
  from _pytest._code.code import ReprEntry
  from _pytest._code.code import ReprEntryNative
  from _pytest._code.code import ReprExceptionInfo
  from _pytest._code.code import ReprFileLocation
  from _pytest._code.code import ReprFuncArgs
  from _pytest._code.code import ReprLocals
  from _pytest._code.code import ReprTraceback
  from _pytest._code.code import TerminalRepr
  from _pytest.outcomes import skip
  from _pytest.pathlib import Path
label_desc: Use image node_id 13 for calling the BaseReport obj's underlying member method code with example usage: obj._from_json(cls, reportdict) and returns: cls