mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
Add wip test for user over widget css, use type alias
This commit is contained in:
@@ -3,12 +3,15 @@ from typing import Any
|
||||
|
||||
import pytest
|
||||
|
||||
from tests.utilities.test_app import AppTest
|
||||
from textual.app import App, ComposeResult
|
||||
from textual.color import Color
|
||||
from textual.css._help_renderables import HelpText
|
||||
from textual.css.stylesheet import Stylesheet, StylesheetParseError
|
||||
from textual.css.tokenizer import TokenizeError
|
||||
from textual.dom import DOMNode
|
||||
from textual.geometry import Spacing
|
||||
from textual.widget import Widget
|
||||
|
||||
|
||||
def _make_stylesheet(css: str) -> Stylesheet:
|
||||
@@ -101,6 +104,24 @@ def test_stylesheet_apply_empty_rulesets():
|
||||
stylesheet.apply(node)
|
||||
|
||||
|
||||
@pytest.mark.xfail(reason="wip")
|
||||
def test_stylesheet_apply_user_css_over_widget_css():
|
||||
user_css = ".a {color: red;}"
|
||||
|
||||
class MyWidget(Widget):
|
||||
CSS = ".a {color: blue;}"
|
||||
|
||||
node = MyWidget()
|
||||
node.add_class("a")
|
||||
|
||||
print(node.styles.color)
|
||||
stylesheet = _make_stylesheet(user_css)
|
||||
stylesheet.apply(node)
|
||||
|
||||
assert node.styles.background == Color(0, 0, 255)
|
||||
# TODO: On Tuesday - writing the tests for prioritising user CSS above widget CSS.
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"css_value,expectation,expected_color",
|
||||
[
|
||||
|
||||
Reference in New Issue
Block a user