mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
[widget] Better tests for types of values we handle or not in style's size
This commit is contained in:
@@ -32,29 +32,3 @@ def test_widget_set_visible_invalid_string():
|
||||
widget.visible = "nope! no widget for me!"
|
||||
|
||||
assert widget.visible
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"size_input, expectation",
|
||||
[
|
||||
(None, does_not_raise()),
|
||||
(10, does_not_raise()),
|
||||
(10.0, does_not_raise()),
|
||||
(10.2, does_not_raise()),
|
||||
(Scalar(100, Unit.CELLS, Unit.WIDTH), does_not_raise()),
|
||||
(Scalar(10.2, Unit.CELLS, Unit.WIDTH), does_not_raise()),
|
||||
("10", does_not_raise()),
|
||||
# And now for some common types we don't handle...
|
||||
("a", pytest.raises(StyleValueError)),
|
||||
(list(), pytest.raises(StyleValueError)),
|
||||
(tuple(), pytest.raises(StyleValueError)),
|
||||
(dict(), pytest.raises(StyleValueError)),
|
||||
(3.14j, pytest.raises(StyleValueError)),
|
||||
(Decimal("3.14"), pytest.raises(StyleValueError)),
|
||||
],
|
||||
)
|
||||
def test_widget_style_size_can_accept_various_data_types(size_input, expectation):
|
||||
widget = Widget()
|
||||
|
||||
with expectation:
|
||||
widget.styles.width = size_input
|
||||
|
||||
Reference in New Issue
Block a user