| 94 | |
| 95 | |
| 96 | def test_parse(): |
| 97 | assert Style.parse("") == Style() |
| 98 | assert Style.parse("red") == Style(color="red") |
| 99 | assert Style.parse("not bold") == Style(bold=False) |
| 100 | assert Style.parse("bold red on black") == Style( |
| 101 | color="red", bgcolor="black", bold=True |
| 102 | ) |
| 103 | assert Style.parse("bold link https://example.org") == Style( |
| 104 | bold=True, link="https://example.org" |
| 105 | ) |
| 106 | with pytest.raises(errors.StyleSyntaxError): |
| 107 | Style.parse("on") |
| 108 | with pytest.raises(errors.StyleSyntaxError): |
| 109 | Style.parse("on nothing") |
| 110 | with pytest.raises(errors.StyleSyntaxError): |
| 111 | Style.parse("rgb(999,999,999)") |
| 112 | with pytest.raises(errors.StyleSyntaxError): |
| 113 | Style.parse("not monkey") |
| 114 | with pytest.raises(errors.StyleSyntaxError): |
| 115 | Style.parse("link") |
| 116 | |
| 117 | |
| 118 | def test_link_id(): |