()
| 11 | |
| 12 | |
| 13 | def test_template_message(): |
| 14 | template = FakeMessage.template("{a:custom}{b:text}{c:image}/{d}") |
| 15 | |
| 16 | @template.add_format_spec |
| 17 | def custom(input: str) -> str: |
| 18 | return f"{input}-custom!" |
| 19 | |
| 20 | with pytest.raises(ValueError, match="already exists"): |
| 21 | template.add_format_spec(custom) |
| 22 | |
| 23 | format_args = { |
| 24 | "a": "custom", |
| 25 | "b": "text", |
| 26 | "c": "https://example.com/test", |
| 27 | "d": 114, |
| 28 | } |
| 29 | formatted = template.format(**format_args) |
| 30 | |
| 31 | assert template.format_map(format_args) == formatted |
| 32 | assert formatted.extract_plain_text() == "custom-custom!text/114" |
| 33 | assert str(formatted) == "custom-custom!text[fake:image]/114" |
| 34 | |
| 35 | |
| 36 | def test_rich_template_message(): |
nothing calls this directly
no test coverage detected