From dc318b8c93965c23496e7a38beab758fa38dd144 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodrigo=20Gir=C3=A3o=20Serr=C3=A3o?= <5621605+rodrigogiraoserrao@users.noreply.github.com> Date: Thu, 12 Jan 2023 14:39:05 +0000 Subject: [PATCH] Update tests. --- tests/css/test_text_style.py | 20 -------------------- tests/test_style_properties.py | 13 +++++++++++++ 2 files changed, 13 insertions(+), 20 deletions(-) delete mode 100644 tests/css/test_text_style.py diff --git a/tests/css/test_text_style.py b/tests/css/test_text_style.py deleted file mode 100644 index ea4c7f1fa..000000000 --- a/tests/css/test_text_style.py +++ /dev/null @@ -1,20 +0,0 @@ -from rich.style import Style - -from textual.css.styles import Styles - - -def test_text_style_none(): - styles = Styles() - styles.text_style = "none" - assert styles.text_style == Style() - - -def test_text_style_none_with_others(): - """Style "none" mixed with others should result in empty style.""" - styles = Styles() - styles.text_style = "bold none underline italic" - - none_styles = Styles() - styles.text_style = "none" - - assert styles.text_style == none_styles.text_style diff --git a/tests/test_style_properties.py b/tests/test_style_properties.py index f8900c1b7..81abe8039 100644 --- a/tests/test_style_properties.py +++ b/tests/test_style_properties.py @@ -1,4 +1,8 @@ +import pytest +from rich.style import Style + from textual.color import Color +from textual.css.errors import StyleValueError from textual.css.styles import Styles @@ -7,3 +11,12 @@ def test_box_normalization(): styles = Styles() styles.border_left = ("none", "red") assert styles.border_left == ("", Color.parse("red")) + + +@pytest.mark.parametrize("style_attr", ["text_style", "link_style"]) +def test_text_style_none_with_others(style_attr): + """Style "none" mixed with others should give custom Textual exception.""" + styles = Styles() + + with pytest.raises(StyleValueError) as exc_info: + setattr(styles, style_attr, "bold none underline italic")