MCPcopy
hub / github.com/pytest-dev/pytest / record_testreport

Method record_testreport

src/_pytest/junitxml.py:114–142  ·  view source on GitHub ↗
(self, testreport: TestReport)

Source from the content-addressed store, hash-verified

112 return None
113
114 def record_testreport(self, testreport: TestReport) -> None:
115 names = mangle_test_address(testreport.nodeid)
116 existing_attrs = self.attrs
117 classnames = names[:-1]
118 if self.xml.prefix:
119 classnames.insert(0, self.xml.prefix)
120 attrs: dict[str, str] = {
121 "classname": ".".join(classnames),
122 "name": bin_xml_escape(names[-1]),
123 "file": testreport.location[0],
124 }
125 if testreport.location[1] is not None:
126 attrs["line"] = str(testreport.location[1])
127 if hasattr(testreport, "url"):
128 attrs["url"] = testreport.url
129 self.attrs = attrs
130 self.attrs.update(existing_attrs) # Restore any user-defined attributes.
131
132 # Preserve legacy testcase behavior.
133 if self.family == "xunit1":
134 return
135
136 # Filter out attributes not permitted by this test family.
137 # Including custom attributes because they are not valid here.
138 temp_attrs = {}
139 for key in self.attrs:
140 if key in families[self.family]["testcase"]:
141 temp_attrs[key] = self.attrs[key]
142 self.attrs = temp_attrs
143
144 def to_xml(self) -> ET.Element:
145 testcase = ET.Element("testcase", self.attrs, time=f"{self.duration:.3f}")

Callers 1

_opentestcaseMethod · 0.80

Calls 5

mangle_test_addressFunction · 0.85
bin_xml_escapeFunction · 0.85
insertMethod · 0.80
joinMethod · 0.80
updateMethod · 0.80

Tested by

no test coverage detected