(self, testreport: TestReport)
| 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) |
no test coverage detected