@@ -44,6 +44,53 @@ async def test_nest_app():
4444 assert app .query_one ("#foo .paul" ).styles .background == Color .parse ("blue" )
4545
4646
47+ class ListOfNestedSelectorsApp (App [None ]):
48+ CSS = """
49+ Label {
50+ &.foo, &.bar {
51+ background: red;
52+ }
53+ }
54+ """
55+
56+ def compose (self ) -> ComposeResult :
57+ yield Label ("one" , classes = "foo" )
58+ yield Label ("two" , classes = "bar" )
59+ yield Label ("three" , classes = "heh" )
60+
61+
62+ async def test_lists_of_selectors_in_nested_css () -> None :
63+ """Regression test for https://github.com/Textualize/textual/issues/3969."""
64+ app = ListOfNestedSelectorsApp ()
65+ red = Color .parse ("red" )
66+ async with app .run_test ():
67+ assert app .query_one (".foo" ).styles .background == red
68+ assert app .query_one (".bar" ).styles .background == red
69+ assert app .query_one (".heh" ).styles .background != red
70+
71+
72+ class DeclarationAfterNestedApp (App [None ]):
73+ CSS = """
74+ Screen {
75+ Label {
76+ background: red;
77+ }
78+ background: green;
79+ }
80+ """
81+
82+ def compose (self ) -> ComposeResult :
83+ yield Label ("one" )
84+
85+
86+ async def test_rule_declaration_after_nested () -> None :
87+ """Regression test for https://github.com/Textualize/textual/issues/3999."""
88+ app = DeclarationAfterNestedApp ()
89+ async with app .run_test ():
90+ assert app .screen .styles .background == Color .parse ("green" )
91+ assert app .query_one (Label ).styles .background == Color .parse ("red" )
92+
93+
4794@pytest .mark .parametrize (
4895 ("css" , "exception" ),
4996 [
0 commit comments