MCPcopy Create free account
hub / github.com/pytest-dev/pytest / record_testreport

Method record_testreport

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

Source from the content-addressed store, hash-verified

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

Callers 1

_opentestcaseMethod · 0.80

Calls 4

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

Tested by

no test coverage detected