mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
test fix
This commit is contained in:
@@ -347,7 +347,7 @@ def parse(
|
||||
path (str): Path to the CSS
|
||||
variables (dict[str, str]): Substitution variables to substitute tokens for.
|
||||
is_default_rules (bool): True if the rules we're extracting are
|
||||
default (i.e. in Widget.CSS) rules. False if they're from user defined CSS.
|
||||
default (i.e. in Widget.DEFAULT_CSS) rules. False if they're from user defined CSS.
|
||||
"""
|
||||
variable_tokens = tokenize_values(variables or {})
|
||||
tokens = iter(substitute_references(tokenize(css, path), variable_tokens))
|
||||
|
||||
@@ -209,7 +209,7 @@ class Stylesheet:
|
||||
css (str): String containing Textual CSS.
|
||||
path (str | PurePath): Path to CSS or unique identifier
|
||||
is_default_rules (bool): True if the rules we're extracting are
|
||||
default (i.e. in Widget.CSS) rules. False if they're from user defined CSS.
|
||||
default (i.e. in Widget.DEFAULT_CSS) rules. False if they're from user defined CSS.
|
||||
|
||||
Raises:
|
||||
StylesheetError: If the CSS is invalid.
|
||||
|
||||
@@ -112,10 +112,12 @@ def test_stylesheet_apply_user_css_over_widget_css():
|
||||
node.add_class("a")
|
||||
|
||||
stylesheet = _make_user_stylesheet(user_css)
|
||||
stylesheet.add_source(MyWidget.CSS, "widget.py:MyWidget", is_default_css=True)
|
||||
stylesheet.add_source(
|
||||
MyWidget.DEFAULT_CSS, "widget.py:MyWidget", is_default_css=True
|
||||
)
|
||||
stylesheet.apply(node)
|
||||
|
||||
# The node is red because user CSS overrides Widget.CSS
|
||||
# The node is red because user CSS overrides Widget.DEFAULT_CSS
|
||||
assert node.styles.color == Color(255, 0, 0)
|
||||
# The background colour defined in the Widget still applies, since user CSS doesn't override it
|
||||
assert node.styles.background == Color(0, 255, 0)
|
||||
|
||||
Reference in New Issue
Block a user