Given a target string, ensure that the string defines the specified node and that the given mappings of fields to values are present in the string. Strips all whitespace in the target and fields. Does not assume any particular ordering for the fields.
(nodename: str, fields: dict[str, str], target: str)
| 59 | |
| 60 | |
| 61 | def assert_fields(nodename: str, fields: dict[str, str], target: str) -> None: |
| 62 | """ |
| 63 | Given a target string, ensure that the string defines the specified node |
| 64 | and that the given mappings of fields to values are present in the string. |
| 65 | Strips all whitespace in the target and fields. |
| 66 | Does not assume any particular ordering for the fields. |
| 67 | """ |
| 68 | stripped_target = strip_whitespace(target) |
| 69 | assert stripped_target.startswith(f"{nodename}(") |
| 70 | for field, value in fields.items(): |
| 71 | assert f"{field}={strip_whitespace(value)}" in stripped_target |
| 72 | |
| 73 | |
| 74 | # test cases are mostly adapted from text_expr, only testing very basic properties |
no test coverage detected
searching dependent graphs…