Extract the first string argument from a test runner call node.
(self, call_node, source: bytes)
| 2203 | _MAX_TEST_DESCRIPTION_LEN = 200 # Cap test description length in node names |
| 2204 | |
| 2205 | def _get_test_description(self, call_node, source: bytes) -> Optional[str]: |
| 2206 | """Extract the first string argument from a test runner call node.""" |
| 2207 | for child in call_node.children: |
| 2208 | if child.type == "arguments": |
| 2209 | for arg in child.children: |
| 2210 | if arg.type in ("string", "template_string"): |
| 2211 | raw = arg.text.decode("utf-8", errors="replace") |
| 2212 | stripped = raw.strip("'\"`") |
| 2213 | normalized = re.sub(r"\s+", " ", stripped).strip() |
| 2214 | if len(normalized) > self._MAX_TEST_DESCRIPTION_LEN: |
| 2215 | normalized = normalized[: self._MAX_TEST_DESCRIPTION_LEN] |
| 2216 | return normalized |
| 2217 | return None |
| 2218 | |
| 2219 | def _extract_from_tree( |
| 2220 | self, |