repo
stringclasses
454 values
file_path
stringlengths
5
201
extension
stringclasses
1 value
content
stringlengths
8
509k
num_lines
int64
3
16.9k
size_bytes
int64
8
511k
textual
tests/layouts/test_content_dimensions.py
.py
import pytest from textual.geometry import Size from textual.layouts.grid import GridLayout from textual.layouts.horizontal import HorizontalLayout from textual.layouts.vertical import VerticalLayout from textual.widget import Widget LAYOUTS = [GridLayout, HorizontalLayout, VerticalLayout] @pytest.mark.parametrize(...
28
1,063
textual
tests/layouts/test_horizontal.py
.py
import pytest from textual.app import App, ComposeResult from textual.containers import Horizontal from textual.widget import Widget @pytest.fixture async def app(): class HorizontalAutoWidth(App): def compose(self) -> ComposeResult: child1 = Widget(id="child1") child1.styles.widt...
30
828
textual
tests/layouts/test_common_layout_features.py
.py
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)...
29
859
textual
tests/layouts/test_grid.py
.py
from textual import containers, widgets from textual.app import App, ComposeResult from textual.layouts.grid import GridLayout async def test_grid_size(): """Test the `grid_size` property on GridLayout.""" class GridApp(App): CSS = """ Grid { grid-size: 3; grid-columns...
35
985
textual
tests/input/test_input_terminal_cursor.py
.py
from textual.app import App, ComposeResult from textual.geometry import Offset from textual.widgets import Input class InputApp(App): # Apply padding to ensure gutter accounted for. CSS = "Input { padding: 4 8 }" def compose(self) -> ComposeResult: # We don't want to select the text on focus, as ...
31
1,053
textual
tests/input/test_input_key_movement_actions.py
.py
"""Unit tests for Input widget position movement actions.""" from __future__ import annotations from textual.app import App, ComposeResult from textual.widgets import Input class InputTester(App[None]): """Input widget testing app.""" def compose(self) -> ComposeResult: for value, input_id in ( ...
186
6,772
textual
tests/input/test_input_replace.py
.py
from __future__ import annotations import pytest from textual.app import App, ComposeResult from textual.widgets import Input _FORWARD_DELETIONS = [ ((0, 0), "0123456789"), # Delete nothing ((0, 10), ""), # Delete all ((0, 1), "123456789"), # Delete first character ((5, 10), "01234"), # Delete la...
65
2,197
textual
tests/input/test_input_restrict.py
.py
import re import pytest from textual.app import App, ComposeResult from textual.widgets import Input from textual.widgets._input import _RESTRICT_TYPES def test_input_number_type(): """Test number type regex, value should be number or the prefix of a valid number""" number = _RESTRICT_TYPES["number"] as...
165
5,386
textual
tests/input/test_input_properties.py
.py
from __future__ import annotations from rich.highlighter import JSONHighlighter from rich.text import Text from textual.app import App, ComposeResult from textual.containers import Container from textual.widgets import Input from textual.widgets.input import Selection class InputApp(App[None]): TEST_TEXT = "Let...
109
3,703
textual
tests/input/test_input_clear.py
.py
from textual.app import App, ComposeResult from textual.widgets import Input class InputApp(App): def compose(self) -> ComposeResult: yield Input("Hello, World!") async def test_input_clear(): async with InputApp().run_test() as pilot: input_widget = pilot.app.query_one(Input) assert...
17
456
textual
tests/input/test_input_key_modification_actions.py
.py
"""Unit tests for Input widget value modification actions.""" from __future__ import annotations from textual.app import App, ComposeResult from textual.widgets import Input TEST_INPUTS: dict[str | None, str] = { "empty": "", "multi-no-punctuation": "Curse your sudden but inevitable betrayal", "multi-pun...
182
7,229
textual
tests/input/test_input_messages.py
.py
from __future__ import annotations from textual import on from textual.app import App, ComposeResult from textual.events import Paste from textual.widgets import Input class InputApp(App[None]): def __init__(self, initial: str | None = None) -> None: super().__init__() self.messages: list[str] = ...
76
2,706
textual
tests/input/test_input_mouse.py
.py
from __future__ import annotations import pytest from textual.app import App, ComposeResult from textual.geometry import Offset from textual.widgets import Input # A string containing only single-width characters TEXT_SINGLE = "That gum you like is going to come back in style" # A string containing only double-widt...
80
2,722
textual
tests/input/test_select_on_focus.py
.py
"""The standard path of selecting text on focus is well covered by snapshot tests.""" from textual import events from textual.app import App, ComposeResult from textual.widgets import Input from textual.widgets.input import Selection class InputApp(App[None]): """An app with an input widget.""" def compose(...
31
1,141
textual
tests/input/test_input_validation.py
.py
import pytest from textual import on from textual.app import App, ComposeResult from textual.validation import Number, ValidationResult from textual.widgets import Input class InputApp(App): def __init__(self, validate_on=None): super().__init__() self.messages = [] self.validator = Numbe...
225
6,449
textual
tests/input/test_cut_copy_paste.py
.py
from textual.app import App, ComposeResult from textual.widgets import Input class InputApp(App): def compose(self) -> ComposeResult: yield Input() async def test_cut(): """Check that cut removes text and places it in the clipboard.""" app = InputApp() async with app.run_test() as pilot: ...
53
1,714
textual
tests/notifications/test_notifications.py
.py
from __future__ import annotations from time import sleep from textual.notifications import Notification, Notifications def test_empty_to_start_with() -> None: """We should have no notifications if we've not raised any.""" assert len(Notifications()) == 0 def test_many_notifications() -> None: """Addi...
79
2,364
textual
tests/notifications/test_all_levels_notifications.py
.py
from textual.app import App, ComposeResult from textual.screen import Screen from textual.widget import Widget class NotifyWidget(Widget): def on_mount(self) -> None: self.notify("test", timeout=60) class NotifyScreen(Screen): def on_mount(self) -> None: self.notify("test", timeout=60) ...
29
743
textual
tests/notifications/test_notification.py
.py
from __future__ import annotations from time import sleep from textual.notifications import Notification def test_message() -> None: """A notification should not change the message.""" assert Notification("test").message == "test" def test_default_title() -> None: """A notification with no title shoul...
41
1,146
textual
tests/notifications/test_app_notifications.py
.py
import asyncio from textual.app import App class NotificationApp(App[None]): pass async def test_app_no_notifications() -> None: """An app with no notifications should have an empty notification list.""" async with NotificationApp().run_test() as pilot: assert len(pilot.app._notifications) == 0...
54
1,917
textual
tests/renderables/test_underline_bar.py
.py
from unittest.mock import create_autospec from rich.console import Console, ConsoleOptions from rich.text import Text from tests.utilities.render import render from textual.renderables.bar import Bar MAGENTA = "\x1b[35m" GREY = "\x1b[38;5;59m" STOP = "\x1b[0m" GREEN = "\x1b[32m" RED = "\x1b[31m" def test_no_highli...
128
3,660
textual
tests/renderables/test_tint.py
.py
import io from rich.console import Console from rich.segment import Segments from rich.terminal_theme import DIMMED_MONOKAI from rich.text import Text from textual._ansi_theme import DEFAULT_TERMINAL_THEME from textual.color import Color from textual.renderables.tint import Tint def test_tint(): console = Conso...
49
1,492
textual
tests/renderables/test_text_opacity.py
.py
import pytest from rich.text import Text from tests.utilities.render import render from textual.renderables.text_opacity import TextOpacity STOP = "\x1b[0m" @pytest.fixture def text(): return Text("Hello, world!", style="#ff0000 on #00ff00", end="") def test_simple_text_opacity(text): blended_red_on_green...
45
1,300
textual
tests/renderables/test_sparkline.py
.py
from collections import UserList, deque from typing import Sequence import pytest from tests.utilities.render import render from textual.renderables.sparkline import Sparkline GREEN = "\x1b[38;2;0;255;0m" RED = "\x1b[38;2;255;0;0m" BLENDED = "\x1b[38;2;127;127;0m" # Color between red and green STOP = "\x1b[0m" de...
105
2,754
textual
tests/tree/test_tree_expand_etc.py
.py
from __future__ import annotations from textual.app import App, ComposeResult from textual.widgets import Tree class TreeApp(App[None]): """Test tree app.""" def compose(self) -> ComposeResult: yield Tree("Test") def on_mount(self) -> None: tree = self.query_one(Tree) for n in r...
107
4,824
textual
tests/tree/test_tree_messages.py
.py
from __future__ import annotations from typing import Any from textual.app import App, ComposeResult from textual.containers import Vertical from textual.widgets import Button, Tree class MyTree(Tree[None]): pass class TreeApp(App[None]): """Test tree app.""" def __init__(self, *args: Any, **kwargs: ...
255
8,875
textual
tests/tree/test_node_refresh.py
.py
from rich.style import Style from rich.text import Text from textual.app import App, ComposeResult from textual.widgets import Tree from textual.widgets.tree import TreeNode class HistoryTree(Tree): def __init__(self) -> None: super().__init__("Root") self.counter = 0 self.render_hits: se...
65
2,462
textual
tests/tree/test_directory_tree.py
.py
from __future__ import annotations from pathlib import Path from rich.text import Text from textual import on from textual.app import App, ComposeResult from textual.widgets import DirectoryTree class DirectoryTreeApp(App[None]): """DirectoryTree test app.""" def __init__(self, path): super().__in...
204
6,743
textual
tests/tree/test_tree_node_children.py
.py
import pytest from textual.widgets import Tree from textual.widgets.tree import TreeNode def label_of(node: TreeNode[None]): """Get the label of a node as a string""" return str(node.label) async def test_tree_node_children() -> None: """A node's children property should act like an immutable list.""" ...
35
1,143
textual
tests/tree/test_tree_node_label.py
.py
from rich.text import Text from textual.widgets import Tree from textual.widgets.tree import TreeNode async def test_tree_node_label() -> None: """It should be possible to modify a TreeNode's label.""" node = TreeNode(Tree[None]("Xenomorph Lifecycle"), None, 0, "Facehugger") assert node.label == Text("Fa...
22
750
textual
tests/tree/test_tree_node_parent.py
.py
from textual.widgets import Tree async def test_tree_node_parent() -> None: """It should be possible to access a TreeNode's parent.""" tree = Tree[None]("Anakin") child = tree.root.add("Leia") grandchild = child.add("Ben") assert tree.root.parent is None assert grandchild.parent == child a...
12
352
textual
tests/tree/test_tree_node_add.py
.py
import pytest from textual.widgets import Tree from textual.widgets.tree import AddNodeError async def test_tree_node_add_before_and_after_raises_exception(): tree = Tree[None]("root") with pytest.raises(AddNodeError): tree.root.add("error", before=99, after=0) async def test_tree_node_add_before_o...
121
4,724
textual
tests/tree/test_tree_get_node_by_id.py
.py
from typing import cast import pytest from textual.widgets import Tree from textual.widgets.tree import NodeID, UnknownNodeID async def test_get_tree_node_by_id() -> None: """It should be possible to get a TreeNode by its ID.""" tree = Tree[None]("Anakin") child = tree.root.add("Leia") grandchild = ...
19
626
textual
tests/tree/test_tree_cursor.py
.py
from __future__ import annotations from typing import Any from textual import on from textual.app import App, ComposeResult from textual.widgets import Tree from textual.widgets.tree import NodeID, TreeNode class TreeApp(App[None]): def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__...
103
3,614
textual
tests/tree/test_tree_clearing.py
.py
from __future__ import annotations import pytest from textual.app import App, ComposeResult from textual.widgets import Tree from textual.widgets.tree import RemoveRootError class VerseBody: pass class VerseStar(VerseBody): pass class VersePlanet(VerseBody): pass class VerseMoon(VerseBody): pa...
111
3,558
textual
tests/tree/test_tree_availability.py
.py
from __future__ import annotations from typing import Any from textual import on from textual.app import App, ComposeResult from textual.widgets import Tree class TreeApp(App[None]): """Test tree app.""" def __init__(self, disabled: bool, *args: Any, **kwargs: Any) -> None: super().__init__(*args, ...
129
4,240
textual
tests/listview/test_inherit_listview.py
.py
from textual.app import App, ComposeResult from textual.binding import Binding from textual.widgets import Label, ListItem, ListView class MyListView(ListView): """Test child class of a ListView.""" BINDINGS = [Binding(key="s", action="set", description="Set")] def __init__(self, items: int = 0) -> None...
61
1,993
textual
tests/listview/test_listview_navigation.py
.py
from textual.app import App, ComposeResult from textual.widgets import Label, ListItem, ListView class ListViewDisabledItemsApp(App[None]): def compose(self) -> ComposeResult: self.highlighted = [] yield ListView( ListItem(Label("0"), disabled=True), ListItem(Label("1")), ...
46
1,357
textual
tests/listview/test_listview_remove_items.py
.py
from __future__ import annotations import pytest from textual.app import App, ComposeResult from textual.widgets import Label, ListItem, ListView class EmptyListViewApp(App[None]): def compose(self) -> ComposeResult: yield ListView() async def test_listview_pop_empty_raises_index_error(): app = Em...
117
4,121
textual
tests/listview/test_listview_initial_index.py
.py
import pytest from textual.app import App, ComposeResult from textual.widgets import Label, ListItem, ListView @pytest.mark.parametrize( "initial_index,expected_index", [ (0, 1), (1, 1), (2, 4), (3, 4), (4, 4), (5, 5), (6, 7), (7, 7), (8...
43
1,266
textual
tests/utilities/render.py
.py
import io import re from rich.console import Console, RenderableType re_link_ids = re.compile(r"id=[\d\.\-]*?;.*?\x1b") def replace_link_ids(render: str) -> str: """Link IDs have a random ID and system path which is a problem for reproducible tests. """ return re_link_ids.sub("id=0;foo\x1b", render)...
24
669
textual
tests/css/test_styles.py
.py
from decimal import Decimal import pytest from rich.style import Style from textual.color import Color from textual.css.errors import StyleValueError from textual.css.scalar import Scalar, Unit from textual.css.styles import RenderStyles, Styles from textual.dom import DOMNode from textual.widget import Widget def ...
206
6,201
textual
tests/css/test_stylesheet.py
.py
from contextlib import nullcontext as does_not_raise import pytest from textual.color import Color from textual.css.stylesheet import CssSource, Stylesheet, StylesheetParseError from textual.css.tokenizer import TokenError from textual.dom import DOMNode from textual.geometry import Spacing from textual.widget import...
296
10,099
textual
tests/css/test_screen_css.py
.py
from textual.app import App from textual.color import Color from textual.screen import Screen from textual.widgets import Label RED = Color(255, 0, 0) GREEN = Color(0, 255, 0) BLUE = Color(0, 0, 255) class BaseScreen(Screen): def compose(self): yield Label("Hello, world!", id="app-css") yield Lab...
309
8,637
textual
tests/css/test_css_reloading.py
.py
import os from pathlib import Path from textual.app import App, ComposeResult from textual.screen import Screen from textual.widgets import Label CSS_PATH = (Path(__file__) / "../css_reloading.tcss").resolve() class BaseScreen(Screen[None]): def compose(self) -> ComposeResult: yield Label("I am the base...
87
2,368
textual
tests/css/test_grid_rows_columns_relative_units.py
.py
""" Regression tests for #1406 https://github.com/Textualize/textual/issues/1406 The scalars in grid-rows and grid-columns were not aware of the dimension they should be relative to. """ from textual.css.parse import parse_declarations from textual.css.scalar import Unit from textual.css.styles import Styles def te...
43
1,285
textual
tests/css/test_mega_stylesheet.py
.py
from pathlib import Path from textual.css.stylesheet import Stylesheet def test_mega_stylesheet() -> None: """It should be possible to load a known-good stylesheet.""" mega_stylesheet = Stylesheet() mega_stylesheet.read(Path(__file__).parent / "test_mega_stylesheet.tcss") mega_stylesheet.parse() ...
12
381
textual
tests/css/test_scalar.py
.py
from textual.css.scalar import Scalar, Unit def test_copy_with_value(): old = Scalar(1, Unit.HEIGHT, Unit.CELLS) new = old.copy_with(value=2) assert new == Scalar(2, Unit.HEIGHT, Unit.CELLS) def test_copy_with_unit(): old = Scalar(1, Unit.HEIGHT, Unit.CELLS) new = old.copy_with(unit=Unit.WIDTH) ...
20
562
textual
tests/css/test_parse.py
.py
from __future__ import annotations import pytest from textual.color import Color from textual.css.errors import UnresolvedVariableError from textual.css.parse import is_id_selector, substitute_references from textual.css.scalar import Scalar, Unit from textual.css.stylesheet import Stylesheet, StylesheetParseError fr...
1,299
38,905
textual
tests/css/test_tokenize.py
.py
from __future__ import annotations import pytest from textual.css.tokenize import tokenize from textual.css.tokenizer import Token, TokenError VALID_VARIABLE_NAMES = [ "warning-text", "warning_text", "warningtext1", "1warningtext", "WarningText1", "warningtext_", "warningtext-", "_war...
981
24,422
textual
tests/css/test_help_text.py
.py
import pytest from tests.utilities.render import render from textual.css._help_text import ( align_help_text, border_property_help_text, color_property_help_text, fractional_property_help_text, layout_property_help_text, offset_property_help_text, offset_single_axis_help_text, scalar_he...
128
4,015
textual
tests/css/test_programmatic_style_changes.py
.py
import pytest from textual.app import App from textual.containers import Grid from textual.widgets import Label @pytest.mark.parametrize( "style, value", [ ("grid_size_rows", 3), ("grid_size_columns", 3), ("grid_gutter_vertical", 4), ("grid_gutter_horizontal", 4), ("gr...
95
2,610
textual
tests/css/test_inheritance.py
.py
import pytest from textual.app import App, ComposeResult from textual.color import Color from textual.widget import Widget class Widget1(Widget): DEFAULT_CSS = """ Widget1 { background: red; } """ class Widget2(Widget1): DEFAULT_CSS = """ Widget1 { background: green; } ...
40
892
textual
tests/css/test_initial.py
.py
from textual.app import App, ComposeResult from textual.color import Color from textual.widget import Widget class Base(Widget): DEFAULT_CSS = """ Base { color: magenta; } """ class CustomWidget1(Base): DEFAULT_CSS = """ CustomWidget1 { background: red } """ class C...
96
2,380
textual
tests/css/test_nested_css.py
.py
from __future__ import annotations import pytest from textual.app import App, ComposeResult from textual.color import Color from textual.containers import Vertical from textual.css.parse import parse from textual.css.tokenizer import TokenError, UnexpectedEnd from textual.widgets import Button, Label class NestedAp...
186
5,622
textual
tests/directory_tree/test_early_show_root.py
.py
from textual.app import App, ComposeResult from textual.widgets import DirectoryTree class DirectoryTreeApp(App[None]): def compose(self) -> ComposeResult: tree = DirectoryTree(".") tree.show_root = True yield tree async def test_managed_to_set_show_root_before_mounted() -> None: """...
17
573
textual
tests/directory_tree/test_change_path.py
.py
from pathlib import Path from textual.app import App, ComposeResult from textual.widgets import DirectoryTree class DirectoryTreeApp(App[None]): def compose(self) -> ComposeResult: yield DirectoryTree(".") async def test_change_directory_tree_path(tmpdir: Path) -> None: """The DirectoryTree should...
21
646
textual
tests/command_palette/test_worker_interference.py
.py
"""Tests for https://github.com/Textualize/textual/issues/3615""" from asyncio import sleep from textual import work from textual.app import App from textual.command import Hit, Hits, Provider class SimpleSource(Provider): async def search(self, query: str) -> Hits: def goes_nowhere_does_nothing() -> No...
51
1,480
textual
tests/command_palette/test_run_on_select.py
.py
from functools import partial from textual.app import App from textual.command import CommandPalette, Hit, Hits, Provider from textual.widgets import Input class SimpleSource(Provider): async def search(self, _: str) -> Hits: def goes_nowhere_does_nothing(selection: int) -> None: assert isins...
68
2,390
textual
tests/command_palette/test_no_results.py
.py
from textual.app import App from textual.command import CommandPalette from textual.widgets import OptionList class CommandPaletteApp(App[None]): COMMANDS = set() def on_mount(self) -> None: self.action_command_palette() async def test_no_results() -> None: """Receiving no results from a search...
28
1,066
textual
tests/command_palette/test_declare_sources.py
.py
from textual.app import App from textual.command import CommandPalette, Hit, Hits, Provider from textual.screen import Screen from textual.system_commands import SystemCommandsProvider async def test_sources_with_no_known_screen() -> None: """A command palette with no known screen should have an empty source set....
101
3,288
textual
tests/command_palette/test_click_away.py
.py
from textual.app import App from textual.command import CommandPalette, Hit, Hits, Provider class SimpleSource(Provider): async def search(self, query: str) -> Hits: def goes_nowhere_does_nothing() -> None: pass yield Hit(1, query, goes_nowhere_does_nothing, query) class CommandPale...
26
792
textual
tests/command_palette/test_events.py
.py
from typing import Union from unittest import mock from textual import on from textual.app import App from textual.command import CommandPalette, Hit, Hits, Provider CommandPaletteEvent = Union[ CommandPalette.Opened, CommandPalette.Closed, CommandPalette.OptionHighlighted ] class SimpleSource(Provider): as...
76
2,153
textual
tests/command_palette/test_discover.py
.py
from textual.app import App from textual.command import CommandPalette, DiscoveryHit, Hit, Hits, Provider from textual.widgets import OptionList class SimpleSource(Provider): async def discover(self) -> Hits: def goes_nowhere_does_nothing() -> None: pass yield DiscoveryHit("XD-1", go...
35
1,052
textual
tests/command_palette/test_escaping.py
.py
from textual.app import App from textual.command import CommandPalette, Hit, Hits, Provider class SimpleSource(Provider): async def search(self, query: str) -> Hits: def goes_nowhere_does_nothing() -> None: pass yield Hit(1, query, goes_nowhere_does_nothing, query) class CommandPale...
26
781
textual
tests/command_palette/test_command_source_environment.py
.py
from __future__ import annotations from textual.app import App, ComposeResult from textual.command import Hit, Hits, Provider from textual.screen import Screen from textual.widget import Widget from textual.widgets import Input class SimpleSource(Provider): environment: set[tuple[App, Screen, Widget | None]] = s...
41
1,247
textual
tests/command_palette/test_interaction.py
.py
from textual.app import App from textual.command import CommandList, CommandPalette, Hit, Hits, Provider class SimpleSource(Provider): async def search(self, query: str) -> Hits: def goes_nowhere_does_nothing() -> None: pass for _ in range(100): yield Hit(1, query, goes_no...
54
2,190
textual
tests/workers/test_worker_manager.py
.py
import asyncio import time from textual.app import App, ComposeResult from textual.widget import Widget from textual.worker import Worker, WorkerState def test_worker_manager_init(): app = App() assert isinstance(repr(app.workers), str) assert not bool(app.workers) assert len(app.workers) == 0 as...
134
3,619
textual
tests/workers/test_work_decorator.py
.py
import asyncio from time import sleep from typing import Callable, List, Tuple import pytest from textual import work from textual._work_decorator import WorkerDeclarationError from textual.app import App from textual.worker import Worker, WorkerState, WorkType class WorkApp(App): worker: Worker def __init...
187
6,140
textual
tests/workers/test_worker.py
.py
import asyncio import pytest from textual.app import App from textual.worker import ( DeadlockError, NoActiveWorker, Worker, WorkerCancelled, WorkerError, WorkerFailed, WorkerState, get_current_worker, ) async def test_initialize(): """Test initial values.""" def foo() -> st...
238
6,227
textual
tests/footer/test_footer.py
.py
from textual.app import App, ComposeResult from textual.binding import Binding from textual.widget import Widget from textual.widgets import Button, Footer async def test_footer_bindings() -> None: app_binding_count = 0 class TestWidget(Widget, can_focus=True): BINDINGS = [ Binding("b", "...
67
1,908
textual
tests/select/test_remove.py
.py
from textual.app import App, ComposeResult from textual.widgets import Header, Select LINES = """I must not fear. Fear is the mind-killer. Fear is the little-death that brings total obliteration. I will face my fear. I will permit it to pass over me and through me.""".splitlines() async def test_select_remove(): ...
26
824
textual
tests/select/test_value.py
.py
import pytest from textual.app import App from textual.widgets import Select from textual.widgets.select import InvalidSelectValueError SELECT_OPTIONS = [(str(n), n) for n in range(3)] MORE_OPTIONS = [(str(n), n) for n in range(5, 8)] class SelectApp(App[None]): def __init__(self, initial_value=Select.NULL): ...
128
3,893
textual
tests/select/test_changed_message.py
.py
from textual import on from textual.app import App from textual.widgets import Select from textual.widgets._select import SelectOverlay class SelectApp(App[None]): def __init__(self): self.changed_messages = [] super().__init__() def compose(self): yield Select[int]([(str(n), n) for n...
68
2,082
textual
tests/select/test_prompt.py
.py
from rich.text import Text from textual.app import App from textual.widgets import Select, Static from textual.widgets._select import SelectCurrent, SelectOverlay async def test_reactive_prompt_change(): """Regression test for https://github.com/Textualize/textual/issues/2983""" class SelectApp(App): ...
55
1,962
textual
tests/select/test_blank_and_clear.py
.py
import pytest from textual.app import App from textual.widgets import Select from textual.widgets.select import InvalidSelectValueError SELECT_OPTIONS = [(str(n), n) for n in range(3)] async def test_value_is_blank_by_default(): class SelectApp(App[None]): def compose(self): yield Select(SEL...
77
2,055
textual
tests/select/test_empty_select.py
.py
import pytest from textual.app import App from textual.widgets import Select from textual.widgets.select import EmptySelectError async def test_empty_select_is_ok_with_blanks(): class SelectApp(App[None]): def compose(self): yield Select([]) app = SelectApp() async with app.run_test(...
54
1,546
textual
tests/snapshot_tests/language_snippets.py
.py
PYTHON = """\ import math from os import path # I'm a comment :) string_var = "Hello, world!" int_var = 42 float_var = 3.14 complex_var = 1 + 2j list_var = [1, 2, 3, 4, 5] tuple_var = (1, 2, 3, 4, 5) set_var = {1, 2, 3, 4, 5} dict_var = {"a": 1, "b": 2, "c": 3} def function_no_args(): return "No arguments" def...
958
19,198
textual
tests/snapshot_tests/test_snapshots.py
.py
from __future__ import annotations import asyncio from pathlib import Path import pytest from rich.panel import Panel from rich.text import Text from tests.snapshot_tests.language_snippets import SNIPPETS from textual import events from textual._on import on from textual import work from textual.app import App, Comp...
4,997
148,164
textual
tests/snapshot_tests/snapshot_apps/scroll_to.py
.py
from textual.app import App, ComposeResult from textual.widgets import Checkbox, Footer class ScrollOffByOne(App): """Scroll to item 50.""" AUTO_FOCUS = None def compose(self) -> ComposeResult: for number in range(1, 100): yield Checkbox(str(number), id=f"number-{number}") yi...
22
486
textual
tests/snapshot_tests/snapshot_apps/programmatic_disable_button.py
.py
from textual.app import App, ComposeResult from textual.containers import Center from textual.widgets import Button, Footer, Label class ExampleApp(App): CSS = """ Screen { align: center middle; } """ BINDINGS = [("space", "toggle_button", "Toggle Button")] def compose(self) -> Compo...
36
900
textual
tests/snapshot_tests/snapshot_apps/nested_specificity.py
.py
from textual.app import App, ComposeResult from textual.widgets import Static class BaseTester(Static, can_focus=True): DEFAULT_CSS = """ BaseTester:focus { background: yellow; border: thick magenta; } """ class NonNestedCSS(BaseTester): DEFAULT_CSS = """ NonNestedCSS { ...
63
1,151
textual
tests/snapshot_tests/snapshot_apps/auto-table.py
.py
from textual.app import App from textual.containers import Container, Horizontal, ScrollableContainer, Vertical from textual.screen import Screen from textual.widgets import DataTable, Header, Label class LabeledBox(Container): DEFAULT_CSS = """ LabeledBox { layers: base_ top_; width: 100%; ...
188
3,818
textual
tests/snapshot_tests/snapshot_apps/footer_toggle_compact.py
.py
from textual.app import App, ComposeResult from textual.widgets import Footer, Label class ToggleCompactFooterApp(App): CSS = """ Screen { align: center middle; } """ BINDINGS = [ ("ctrl+t", "toggle_compact_footer", "Toggle Compact Footer"), ] def compose(self) -> Compose...
34
835
textual
tests/snapshot_tests/snapshot_apps/auto_grid_default_height.py
.py
from __future__ import annotations from typing import Type from textual.app import App, ComposeResult from textual.containers import Container, Horizontal, Vertical, Grid from textual.widgets import Header, Footer, Label from textual.binding import Binding class GridHeightAuto(App[None]): CSS = """ #test-are...
59
1,522
textual
tests/snapshot_tests/snapshot_apps/datatable_hot_reloading.py
.py
from pathlib import Path from textual.app import App, ComposeResult from textual.widgets import DataTable CSS_PATH = (Path(__file__) / "../datatable_hot_reloading.tcss").resolve() # Write some CSS to the file before the app loads. # Then, the test will clear all the CSS to see if the # hot reloading applies the chan...
59
1,260
textual
tests/snapshot_tests/snapshot_apps/split.py
.py
from textual.app import App, ComposeResult from textual.widgets import Placeholder class SplitApp(App): CSS = """ #split1 { split: right; width: 20; } #split2 { split: bottom; height: 10; } #split3 { split: top; height: 6; } #split4 {...
49
946
textual
tests/snapshot_tests/snapshot_apps/command_palette_dismiss.py
.py
from textual.app import App, ComposeResult from textual.widgets import Label class CPApp(App): def compose(self) -> ComposeResult: yield Label("Command palette test app") if __name__ == "__main__": app = CPApp() app.run()
13
246
textual
tests/snapshot_tests/snapshot_apps/data_table_auto_height.py
.py
from textual.app import App, ComposeResult from textual.widgets import DataTable, Label LORUM_IPSUM = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua." class ExampleApp(App): CSS = """ Screen { DataTable { ...
39
1,014
textual
tests/snapshot_tests/snapshot_apps/command_palette_discovery.py
.py
from textual.app import App from textual.command import DiscoveryHit, Hit, Hits, Provider class TestSource(Provider): def goes_nowhere_does_nothing(self) -> None: pass async def discover(self) -> Hits: for n in range(10): command = f"This is a test of this code {n}" yi...
39
991
textual
tests/snapshot_tests/snapshot_apps/dock_scroll_off_by_one.py
.py
from textual.app import App, ComposeResult from textual.widgets import Checkbox, Footer class ScrollOffByOne(App): AUTO_FOCUS = None def compose(self) -> ComposeResult: for number in range(1, 100): yield Checkbox(str(number)) yield Footer() def on_mount(self) -> None: ...
20
412
textual
tests/snapshot_tests/snapshot_apps/visibility.py
.py
from textual.app import App from textual.containers import VerticalScroll from textual.widgets import Static class Visibility(App): """Check that visibility: hidden also makes children invisible;""" CSS = """ Screen { layout: horizontal; } VerticalScroll { width: 1fr; ...
48
961
textual
tests/snapshot_tests/snapshot_apps/listview_index.py
.py
from textual.app import App, ComposeResult from textual.reactive import reactive from textual.widgets import Label, ListItem, ListView class ListViewIndexApp(App): CSS = """ ListView { height: 10; } """ data = reactive(list(range(6))) def __init__(self) -> None: super().__ini...
36
831
textual
tests/snapshot_tests/snapshot_apps/tree_clearing.py
.py
from textual.app import App, ComposeResult from textual.widgets import Tree class TreeClearingSnapshotApp(App[None]): CSS = """ Screen { layout: horizontal; } """ @staticmethod def _populate(tree: Tree) -> Tree: for n in range(5): branch = tree.root.add(str(n)) ...
31
805
textual
tests/snapshot_tests/snapshot_apps/markdown_theme_switcher.py
.py
from textual.app import App, ComposeResult from textual.widgets import Markdown TEST_CODE_MARKDOWN = """ # This is a H1 ```python def main(): print("Hello world!") ``` """ class MarkdownThemeSwitcherApp(App[None]): BINDINGS = [ ("t", "toggle_theme"), ("d", "switch_dark"), ("l", "switc...
37
877
textual
tests/snapshot_tests/snapshot_apps/zero_scrollbar_size.py
.py
from textual.app import App, ComposeResult from textual.widgets import Static class TestApp(App): DEFAULT_CSS = """ Screen { scrollbar-size: 0 0; } """ def compose(self) -> ComposeResult: yield Static("Hello, world!\n" * 100) if __name__ == "__main__": TestApp().run()
18
314
textual
tests/snapshot_tests/snapshot_apps/table_markup.py
.py
from textual.app import App, ComposeResult from textual.widgets import Static from rich.table import Table class TableStaticApp(App): def compose(self) -> ComposeResult: table = Table("[i green]Foo", "Bar", "baz") table.add_row("Hello [bold magenta]World!", "[i]Italic", "[u]Underline") yi...
17
408
textual
tests/snapshot_tests/snapshot_apps/horizontal_auto_width.py
.py
from textual.app import App, ComposeResult from textual.containers import Horizontal from textual.widgets import Static class HorizontalAutoWidth(App): """ Checks that the auto width of the parent Horizontal is correct. """ def compose(self) -> ComposeResult: yield Horizontal( Sta...
24
652
textual
tests/snapshot_tests/snapshot_apps/enter_or_leave.py
.py
from textual import on from textual.app import App, ComposeResult from textual.widgets import Label from textual.widget import Widget from textual import events class MyWidget(Widget): def compose(self) -> ComposeResult: yield Label("Foo", id="foo") yield Label("Bar") @on(events.Enter) @o...
45
849
textual
tests/snapshot_tests/snapshot_apps/richlog_width.py
.py
from textual.app import App, ComposeResult from textual.events import Resize from textual.widgets import RichLog from rich.text import Text class RichLogWidth(App[None]): def compose(self) -> ComposeResult: rich_log = RichLog(min_width=20) rich_log.display = False rich_log.write( ...
34
1,120