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