mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
Merge branch 'css' into table-layout
This commit is contained in:
@@ -2,7 +2,6 @@ from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
from textual.color import Color
|
||||
from textual.css.errors import UnresolvedVariableError
|
||||
from textual.css.parse import substitute_references
|
||||
@@ -1131,3 +1130,27 @@ class TestParsePadding:
|
||||
stylesheet = Stylesheet()
|
||||
stylesheet.add_source(css)
|
||||
assert stylesheet.rules[0].styles.padding == Spacing(2, 3, -1, 1)
|
||||
|
||||
|
||||
class TestParseTextAlign:
|
||||
@pytest.mark.parametrize("valid_align", ["left", "start", "center", "right", "end", "justify"])
|
||||
def test_text_align(self, valid_align):
|
||||
css = f"#foo {{ text-align: {valid_align} }}"
|
||||
stylesheet = Stylesheet()
|
||||
stylesheet.add_source(css)
|
||||
assert stylesheet.rules[0].styles.text_align == valid_align
|
||||
|
||||
def test_text_align_invalid(self):
|
||||
css = "#foo { text-align: invalid-value; }"
|
||||
stylesheet = Stylesheet()
|
||||
with pytest.raises(StylesheetParseError):
|
||||
stylesheet.add_source(css)
|
||||
stylesheet.parse()
|
||||
rules = stylesheet._parse_rules(css, "foo")
|
||||
assert rules[0].errors
|
||||
|
||||
def test_text_align_empty_uses_default(self):
|
||||
css = "#foo { text-align: ; }"
|
||||
stylesheet = Stylesheet()
|
||||
stylesheet.add_source(css)
|
||||
assert stylesheet.rules[0].styles.text_align == "start"
|
||||
|
||||
@@ -25,4 +25,4 @@ def test_auto_refresh():
|
||||
elapsed = app.run(quit_after=1, headless=True)
|
||||
assert elapsed is not None
|
||||
# CI can run slower, so we need to give this a bit of margin
|
||||
assert elapsed >= 0.3 and elapsed < 0.6
|
||||
assert 0.2 <= elapsed < 0.8
|
||||
|
||||
Reference in New Issue
Block a user