File: test_common_layout_features.py

package info (click to toggle)
textual 2.1.2-1.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 55,080 kB
  • sloc: python: 85,423; lisp: 1,669; makefile: 101
file content (28 lines) | stat: -rw-r--r-- 859 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import pytest

from textual.screen import Screen
from textual.widget import Widget


@pytest.mark.parametrize(
    "layout,display,expected_in_displayed_children",
    [
        ("horizontal", "block", True),
        ("vertical", "block", True),
        ("horizontal", "none", False),
        ("vertical", "none", False),
    ],
)
def test_nodes_take_display_property_into_account_when_they_display_their_children(
    layout: str, display: str, expected_in_displayed_children: bool
):
    widget = Widget(name="widget that might not be visible 🥷 ")
    widget.styles.display = display

    screen = Screen()
    screen.styles.layout = layout
    screen._add_child(widget)

    displayed_children = screen.displayed_children
    assert isinstance(displayed_children, list)
    assert (widget in screen.displayed_children) is expected_in_displayed_children