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
docs/examples/styles/link_style.py
.py
from textual.app import App from textual.widgets import Label class LinkStyleApp(App): CSS_PATH = "link_style.tcss" def compose(self): yield Label( "Visit the [link='https://textualize.io']Textualize[/link] website.", id="lbl1", # (1)! ) yield Label( ...
30
747
textual
docs/examples/styles/width.py
.py
from textual.app import App from textual.widget import Widget class WidthApp(App): CSS_PATH = "width.tcss" def compose(self): yield Widget() if __name__ == "__main__": app = WidthApp() app.run()
15
224
textual
docs/examples/styles/scrollbars.py
.py
from textual.app import App from textual.containers import Horizontal, ScrollableContainer from textual.widgets import Label TEXT = """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. And when it has...
28
753
textual
docs/examples/styles/text_style.py
.py
from textual.app import App from textual.widgets import Label TEXT = """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. And when it has gone past, I will turn the inner eye to see its path. Where th...
25
645
textual
docs/examples/styles/background_transparency.py
.py
from textual.app import App, ComposeResult from textual.widgets import Static class BackgroundTransparencyApp(App): """Simple app to exemplify different transparency settings.""" CSS_PATH = "background_transparency.tcss" def compose(self) -> ComposeResult: yield Static("10%", id="t10") y...
26
736
textual
docs/examples/styles/grid_rows.py
.py
from textual.app import App from textual.containers import Grid from textual.widgets import Label class MyApp(App): CSS_PATH = "grid_rows.tcss" def compose(self): yield Grid( Label("1fr"), Label("1fr"), Label("height = 6"), Label("height = 6"), ...
27
553
textual
docs/examples/styles/position.py
.py
from textual.app import App, ComposeResult from textual.widgets import Label class PositionApp(App): CSS_PATH = "position.tcss" def compose(self) -> ComposeResult: yield Label("Absolute", id="label1") yield Label("Relative", id="label2") if __name__ == "__main__": app = PositionApp() ...
16
332
textual
docs/examples/styles/text_align.py
.py
from textual.app import App from textual.containers import Grid from textual.widgets import Label TEXT = ( "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." ) class TextAlign(App...
27
718
textual
docs/examples/styles/background.py
.py
from textual.app import App from textual.widgets import Label class BackgroundApp(App): CSS_PATH = "background.tcss" def compose(self): yield Label("Widget 1", id="static1") yield Label("Widget 2", id="static2") yield Label("Widget 3", id="static3") if __name__ == "__main__": ap...
17
354
textual
docs/examples/styles/dock_all.py
.py
from textual.app import App from textual.containers import Container from textual.widgets import Label class DockAllApp(App): CSS_PATH = "dock_all.tcss" def compose(self): yield Container( Container(Label("left"), id="left"), Container(Label("top"), id="top"), Cont...
22
516
textual
docs/examples/styles/link_background_hover.py
.py
from textual.app import App from textual.widgets import Label class LinkHoverBackgroundApp(App): CSS_PATH = "link_background_hover.tcss" def compose(self): yield Label( "Visit the [link='https://textualize.io']Textualize[/link] website.", id="lbl1", # (1)! ) y...
30
778
textual
docs/examples/app/question02.py
.py
from textual.app import App, ComposeResult from textual.widgets import Button, Label class QuestionApp(App[str]): CSS_PATH = "question02.tcss" def compose(self) -> ComposeResult: yield Label("Do you love Textual?", id="question") yield Button("Yes", id="yes", variant="primary") yield ...
21
551
textual
docs/examples/app/widgets01.py
.py
from textual.app import App, ComposeResult from textual.widgets import Welcome class WelcomeApp(App): def compose(self) -> ComposeResult: yield Welcome() def on_button_pressed(self) -> None: self.exit() if __name__ == "__main__": app = WelcomeApp() app.run()
16
296
textual
docs/examples/app/simple02.py
.py
from textual.app import App class MyApp(App): pass if __name__ == "__main__": app = MyApp() app.run()
11
118
textual
docs/examples/app/question_title01.py
.py
from textual.app import App, ComposeResult from textual.widgets import Button, Header, Label class MyApp(App[str]): CSS_PATH = "question02.tcss" TITLE = "A Question App" SUB_TITLE = "The most important question" def compose(self) -> ComposeResult: yield Header() yield Label("Do you lo...
24
645
textual
docs/examples/app/question03.py
.py
from textual.app import App, ComposeResult from textual.widgets import Label, Button class QuestionApp(App[str]): CSS = """ Screen { layout: grid; grid-size: 2; grid-gutter: 2; padding: 2; } #question { width: 100%; height: 100%; column-span: 2; ...
39
841
textual
docs/examples/app/widgets04.py
.py
from textual.app import App from textual.widgets import Button, Welcome class WelcomeApp(App): async def on_key(self) -> None: await self.mount(Welcome()) self.query_one(Button).label = "YES!" if __name__ == "__main__": app = WelcomeApp() app.run()
14
281
textual
docs/examples/app/widgets02.py
.py
from textual.app import App from textual.widgets import Welcome class WelcomeApp(App): def on_key(self) -> None: self.mount(Welcome()) def on_button_pressed(self) -> None: self.exit() if __name__ == "__main__": app = WelcomeApp() app.run()
16
277
textual
docs/examples/app/question01.py
.py
from textual.app import App, ComposeResult from textual.widgets import Label, Button class QuestionApp(App[str]): def compose(self) -> ComposeResult: yield Label("Do you love Textual?") yield Button("Yes", id="yes", variant="primary") yield Button("No", id="no", variant="error") def o...
19
502
textual
docs/examples/app/simple01.py
.py
from textual.app import App class MyApp(App): pass
6
57
textual
docs/examples/app/widgets03.py
.py
from textual.app import App from textual.widgets import Button, Welcome class WelcomeApp(App): def on_key(self) -> None: self.mount(Welcome()) self.query_one(Button).label = "YES!" if __name__ == "__main__": app = WelcomeApp() app.run()
14
269
textual
docs/examples/app/event01.py
.py
from textual.app import App from textual import events class EventApp(App): COLORS = [ "white", "maroon", "red", "purple", "fuchsia", "olive", "yellow", "navy", "teal", "aqua", ] def on_mount(self) -> None: self.scre...
31
574
textual
docs/examples/app/question_title02.py
.py
from textual.app import App, ComposeResult from textual.events import Key from textual.widgets import Button, Header, Label class MyApp(App[str]): CSS_PATH = "question02.tcss" TITLE = "A Question App" SUB_TITLE = "The most important question" def compose(self) -> ComposeResult: yield Header()...
29
800
textual
docs/examples/app/suspend.py
.py
from os import system from textual import on from textual.app import App, ComposeResult from textual.widgets import Button class SuspendingApp(App[None]): def compose(self) -> ComposeResult: yield Button("Open the editor", id="edit") @on(Button.Pressed, "#edit") def run_external_editor(self) ->...
21
445
textual
docs/examples/app/suspend_process.py
.py
from textual.app import App, ComposeResult from textual.binding import Binding from textual.widgets import Label class SuspendKeysApp(App[None]): BINDINGS = [Binding("ctrl+z", "suspend_process")] def compose(self) -> ComposeResult: yield Label("Press Ctrl+Z to suspend!") if __name__ == "__main__":...
16
348
textual
tests/test_partition.py
.py
from textual._partition import partition def test_partition(): def is_odd(value: int) -> bool: return bool(value % 2) def is_greater_than_five(value: int) -> bool: return value > 5 assert partition(is_odd, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == ( [2, 4, 6, 8, 10], [1, 3, 5, ...
28
778
textual
tests/test_concurrency.py
.py
from threading import Thread import pytest from textual.app import App, ComposeResult from textual.widgets import RichLog def test_call_from_thread_app_not_running(): app = App() # Should fail if app is not running with pytest.raises(RuntimeError): app.call_from_thread(print) def test_call_fr...
55
1,634
textual
tests/test_node_list.py
.py
import pytest from textual._node_list import NodeList from textual.widget import Widget def test_empty_list(): """Does an empty node list report as being empty?""" assert len(NodeList()) == 0 async def test_add_one(): """Does adding a node to the node list report as having one item?""" nodes = Node...
114
2,824
textual
tests/test_markdownviewer.py
.py
from pathlib import Path import pytest from rich.text import Text import textual.widgets._markdown as MD from textual.app import App, ComposeResult from textual.content import Content from textual.geometry import Offset from textual.widgets import Markdown, MarkdownViewer, Tree TEST_MARKDOWN = """\ * [First]({{file}...
92
3,272
textual
tests/test_tabbed_content.py
.py
from __future__ import annotations import pytest from textual.app import App, ComposeResult from textual.reactive import var from textual.widgets import Label, Tab, TabbedContent, TabPane, Tabs from textual.widgets._tabbed_content import ContentTab async def test_tabbed_content_switch_via_ui(): """Check tab nav...
917
32,374
textual
tests/test_screen_modes.py
.py
from itertools import cycle from typing import Type import pytest from textual.app import ( ActiveModeError, App, ComposeResult, InvalidModeError, UnknownModeError, ) from textual.screen import ModalScreen, Screen from textual.widgets import Footer, Header, Label class ScreenBindingsMixin(Screen...
232
6,305
textual
tests/test_collapsible.py
.py
from __future__ import annotations from textual import on from textual.app import App, ComposeResult from textual.widgets import Collapsible, Label from textual.widgets._collapsible import CollapsibleTitle COLLAPSED_CLASS = "-collapsed" def get_title(collapsible: Collapsible) -> CollapsibleTitle: return collaps...
248
7,896
textual
tests/test_rlock.py
.py
import asyncio import pytest from textual.rlock import RLock async def test_simple_lock(): lock = RLock() # Starts not locked assert not lock.is_locked # Acquire the lock await lock.acquire() assert lock.is_locked # Acquire a second time (should not block) await lock.acquire() as...
57
1,270
textual
tests/test_widget_mounting.py
.py
import pytest from textual.app import App from textual.css.query import TooManyMatches from textual.widget import MountError, Widget, WidgetError from textual.widgets import Static class SelfOwn(Widget): """Test a widget that tries to own itself.""" def __init__(self) -> None: super().__init__(self)...
126
4,855
textual
tests/test_layout_resolve.py
.py
from __future__ import annotations from typing import NamedTuple import pytest from textual._layout_resolve import layout_resolve class Edge(NamedTuple): size: int | None = None fraction: int = 1 min_size: int = 1 def test_empty(): assert layout_resolve(10, []) == [] def test_total_zero(): ...
102
3,338
textual
tests/test_driver.py
.py
from textual import on from textual.app import App from textual.events import Click, MouseDown, MouseUp from textual.widgets import Button async def test_driver_mouse_down_up_click(): """Mouse down and up should issue a click.""" class MyApp(App): messages = [] @on(Click) @on(MouseDo...
128
3,899
textual
tests/test_geometry.py
.py
from typing import Literal import pytest from textual.geometry import Offset, Region, Shape, Size, Spacing, clamp def test_dimensions_region(): assert Size(30, 40).region == Region(0, 0, 30, 40) def test_dimensions_contains(): assert Size(10, 10).contains(5, 5) assert Size(10, 10).contains(9, 9) a...
834
22,314
textual
tests/test_log.py
.py
from textual.app import App, ComposeResult from textual.widgets import Log async def test_process_line(): log = Log() assert log._process_line("foo") == "foo" assert log._process_line("foo\t") == "foo " assert log._process_line("\0foo") == "�foo" async def test_disabled_log_no_attribute_error() ...
26
808
textual
tests/test_wrap.py
.py
import pytest from textual._wrap import chunks, compute_wrap_offsets @pytest.mark.parametrize( "input_text, expected_output", [ ("", []), (" ", [(0, 4, " ")]), ("\t", [(0, 1, "\t")]), ("foo", [(0, 3, "foo")]), (" foo ", [(0, 2, " "), (2, 7, "foo ")]), ...
44
1,472
textual
tests/test_widget_mount_point.py
.py
import pytest from textual.widget import MountError, Widget class Content(Widget): pass class Body(Widget): pass async def test_find_dom_spot(): # Build up a "fake" DOM for an application. screen = Widget(name="Screen") header = Widget(name="Header", id="header") body = Body(id="body") ...
40
1,295
textual
tests/test_suspend.py
.py
import sys import pytest from textual.app import App, SuspendNotSupported from textual.drivers.headless_driver import HeadlessDriver async def test_suspend_not_supported() -> None: """Suspending when not supported should raise an error.""" async with App().run_test() as pilot: # Pilot uses the headl...
64
2,119
textual
tests/test_call_x_schedulers.py
.py
import asyncio from textual._context import active_message_pump from textual.app import App from textual.message_pump import MessagePump class CallLaterApp(App[None]): def __init__(self) -> None: self.display_count = 0 super().__init__() def post_display_hook(self) -> None: self.disp...
51
1,432
textual
tests/test_links.py
.py
from textual.app import App, ComposeResult from textual.screen import Screen from textual.widgets import Label async def test_links() -> None: """Regression test for https://github.com/Textualize/textual/issues/4536""" messages: list[str] = [] class LinkLabel(Label): def action_bell_message(self,...
38
1,391
textual
tests/test_pipe.py
.py
import subprocess import sys from pathlib import Path import pytest skip_windows = pytest.mark.skipif( sys.platform == "win32", reason="Syntax not supported on Windows" ) @skip_windows def test_deadlock(): """Regression test for https://github.com/Textualize/textual/issues/4643""" app_path = (Path(__fil...
22
570
textual
tests/test_visible.py
.py
from textual.app import App, ComposeResult from textual.containers import VerticalScroll from textual.widget import Widget async def test_visibility_changes() -> None: """Test changing visibility via code and CSS. See https://github.com/Textualize/textual/issues/1355 as the motivation for these tests. ""...
79
2,647
textual
tests/test_resolve.py
.py
from fractions import Fraction import pytest from textual._resolve import resolve, resolve_fraction_unit from textual.css.scalar import Scalar from textual.geometry import Size from textual.widget import Widget def test_resolve_empty(): assert resolve([], 10, 1, Size(20, 10), Size(80, 24)) == [] @pytest.mark....
169
4,128
textual
tests/test_segment_tools.py
.py
from rich.segment import Segment from rich.style import Style from textual._segment_tools import align_lines, line_crop, line_pad, line_trim from textual.geometry import Size def test_line_crop(): bold = Style(bold=True) italic = Style(italic=True) segments = [ Segment("Hello", bold), Seg...
196
6,131
textual
tests/test_header.py
.py
from textual.app import App from textual.screen import Screen from textual.widgets import Header, Static async def test_screen_title_none_is_ignored(): class MyScreen(Screen): def compose(self): yield Header() class MyApp(App): TITLE = "app title" def on_mount(self): ...
141
3,492
textual
tests/test_data_bind.py
.py
import pytest from textual.app import App, ComposeResult from textual.reactive import ReactiveError, reactive from textual.widgets import Label class FooLabel(Label): foo = reactive("Foo") def render(self) -> str: return self.foo class DataBindApp(App): bar = reactive("Bar") def compose(s...
87
2,350
textual
tests/test_strip.py
.py
import pytest from rich.console import Console from rich.segment import Segment from rich.style import Style from textual._segment_tools import NoCellPositionForIndex from textual.color import Color from textual.filter import Monochrome from textual.strip import Strip def test_cell_length() -> None: strip = Stri...
208
6,003
textual
tests/test_app.py
.py
import asyncio import contextlib import pytest from rich.terminal_theme import DIMMED_MONOKAI, MONOKAI, NIGHT_OWLISH from textual import events from textual.app import App, ComposeResult from textual.command import SimpleCommand from textual.pilot import Pilot, _get_mouse_message_arguments from textual.screen import ...
426
11,790
textual
tests/test_mount.py
.py
"""Regression test for https://github.com/Textualize/textual/issues/2914 Make sure that calls to render only happen after a widget being mounted. """ import asyncio from textual.app import App from textual.widget import Widget class W(Widget): def render(self): return self.renderable async def on_...
28
653
textual
tests/test_disabled.py
.py
"""Test Widget.disabled.""" import pytest from textual.app import App, ComposeResult from textual.containers import Vertical, VerticalScroll from textual.widgets import ( Button, Checkbox, DataTable, DirectoryTree, Input, Label, ListItem, ListView, Markdown, MarkdownViewer, ...
150
4,664
textual
tests/test_await_remove.py
.py
from textual.app import App from textual.widgets import Label class SelfRemovingLabel(Label): async def on_mount(self) -> None: await self.remove() class RemoveOnTimerApp(App[None]): def on_mount(self): for _ in range(5): self.mount(SelfRemovingLabel("I will remove myself!")) a...
22
670
textual
tests/test_animation.py
.py
from time import perf_counter from textual.app import App, ComposeResult from textual.reactive import var from textual.widgets import Static class AnimApp(App): CSS = """ #foo { height: 1; } """ def compose(self) -> ComposeResult: yield Static("foo", id="foo") async def test_an...
302
9,584
textual
tests/test_widget_navigation.py
.py
from __future__ import annotations import pytest from textual._widget_navigation import ( find_first_enabled, find_last_enabled, find_next_enabled, find_next_enabled_no_wrap, get_directed_distance, ) class _D: def __init__(self, disabled): self.disabled = disabled # Represent disab...
155
4,414
textual
tests/test_auto_scroll.py
.py
import pytest from textual._auto_scroll import get_auto_scroll_regions from textual.geometry import Region @pytest.mark.parametrize( "region, lines, expected", [ # Simple case ( Region(0, 0, 100, 20), 1, (Region(0, 0, 100, 1), Region(0, 19, 100, 1)), ...
44
1,146
textual
tests/test_lazy.py
.py
from textual.app import App, ComposeResult from textual.containers import Horizontal, Vertical from textual.lazy import Lazy, Reveal from textual.widgets import Label class LazyApp(App): def compose(self) -> ComposeResult: with Vertical(): with Lazy(Horizontal()): yield Label(i...
56
1,606
textual
tests/deadlock.py
.py
""" Called by test_pipe.py """ from textual.app import App from textual.binding import Binding from textual.widgets import Footer class MyApp(App[None]): BINDINGS = [ Binding(key="q", action="quit", description="Quit the app"), ] def compose(self): yield Footer() app = MyApp() app.run...
22
323
textual
tests/test_paste.py
.py
from textual import events from textual.app import App from textual.widgets import Input async def test_paste_app(): paste_events = [] class PasteApp(App): def on_paste(self, event): paste_events.append(event) app = PasteApp() async with app.run_test() as pilot: app.post_...
46
1,162
textual
tests/test_content_switcher.py
.py
from __future__ import annotations import pytest from textual.app import App, ComposeResult from textual.css.query import NoMatches from textual.widget import Widget from textual.widgets import ContentSwitcher class SwitcherApp(App[None]): def __init__(self, initial: str | None = None) -> None: super()....
123
5,202
textual
tests/test_switch.py
.py
from textual.app import App, ComposeResult from textual.widgets import Switch async def test_switch_click_doesnt_bubble_up(): """Regression test for https://github.com/Textualize/textual/issues/2366""" class SwitchApp(App[None]): def compose(self) -> ComposeResult: yield Switch() ...
19
571
textual
tests/test_version.py
.py
import re # https://stackoverflow.com/questions/37972029/regex-to-match-pep440-compliant-version-strings VERSION_PATTERN = r""" v? (?: (?:(?P<epoch>[0-9]+)!)? # epoch (?P<release>[0-9]+(?:\.[0-9]+)*) # release segment (?P<pre> ...
42
1,233
textual
tests/test_getters.py
.py
import pytest from textual import containers, getters from textual.app import App, ComposeResult from textual.css.query import NoMatches, WrongType from textual.widget import Widget from textual.widgets import Input, Label async def test_getters() -> None: """Check the getter descriptors work, and return expecte...
62
1,779
textual
tests/test_features.py
.py
from __future__ import annotations from textual.app import App async def test_textual_env_var(monkeypatch): monkeypatch.setenv("TEXTUAL", "") app = App() assert app.features == set() assert app.devtools is None assert app.debug is False monkeypatch.setenv("TEXTUAL", "devtools") app = App...
30
796
textual
tests/test_box_model.py
.py
from __future__ import annotations from fractions import Fraction from textual.box_model import BoxModel from textual.geometry import Size, Spacing from textual.widget import Widget async def test_content_box(): one = Fraction(1) class TestWidget(Widget): def get_content_width(self, container: Size...
190
6,248
textual
tests/test_tooltips.py
.py
"""Tests for the tooltips.""" from typing_extensions import Final from textual.app import App, ComposeResult from textual.widgets import Static class TooltipApp(App[None]): TOOLTIP_DELAY = 0.4 CSS = """ Static { width: 1fr; height: 1fr; } """ @staticmethod def tip(static...
119
4,975
textual
tests/test_app_focus_blur.py
.py
"""Test the workings of reacting to AppFocus and AppBlur.""" from textual.app import App, ComposeResult from textual.events import AppBlur, AppFocus from textual.widgets import Input class FocusBlurApp(App[None]): AUTO_FOCUS = "#input-4" def compose(self) -> ComposeResult: for n in range(10): ...
80
2,840
textual
tests/test_animator.py
.py
from __future__ import annotations from dataclasses import dataclass from unittest.mock import Mock import pytest from textual._animator import Animator, SimpleAnimation from textual._easing import DEFAULT_EASING, EASING class Animatable: """An animatable object.""" def __init__(self, value): self...
293
7,495
textual
tests/test_arrange.py
.py
import pytest from textual._arrange import TOP_Z, arrange from textual._context import active_app from textual.app import App from textual.geometry import NULL_OFFSET, Region, Size, Spacing from textual.layout import WidgetPlacement from textual.widget import Widget async def test_arrange_empty(): container = Wi...
128
3,608
textual
tests/test_binding_inheritance.py
.py
"""Tests relating to key binding inheritance. In here you'll find some tests for general key binding inheritance, but there is an emphasis on the inheriting of movement key bindings as they (as of the time of writing) hold a special place in the Widget hierarchy of Textual. <URL:https://github.com/Textualize/textual/...
643
24,202
textual
tests/test_message_handling.py
.py
from textual.app import App, ComposeResult from textual.message import Message from textual.widget import Widget async def test_message_inheritance_namespace(): """Inherited messages get their correct namespaces. Regression test for https://github.com/Textualize/textual/issues/1814. """ class BaseWi...
51
1,315
textual
tests/test_constants.py
.py
from textual.constants import _get_environ_bool, _get_environ_int, _get_environ_port def test_environ_int(monkeypatch): """Check minimum is applied.""" monkeypatch.setenv("FOO", "-1") assert _get_environ_int("FOO", 1, minimum=0) == 0 monkeypatch.setenv("FOO", "0") assert _get_environ_int("FOO", 1,...
32
1,090
textual
tests/test_binary_encode.py
.py
import pytest from textual._binary_encode import DecodeError, dump, load @pytest.mark.parametrize( "data", [ None, False, True, -10, -1, 0, 1, 100, "", "💩", "Hello", b"World", b"", [], (),...
91
1,747
textual
tests/test_file_monitor.py
.py
import os from pathlib import Path from textual.file_monitor import FileMonitor def test_repr() -> None: file_monitor = FileMonitor([Path(".")], lambda: None) assert "FileMonitor" in repr(file_monitor) def test_file_never_found(): path = "doesnt_exist.tcss" file_monitor = FileMonitor([Path(path)], ...
59
1,711
textual
tests/test_spatial_map.py
.py
import pytest from textual._spatial_map import SpatialMap from textual.geometry import Offset, Region @pytest.mark.parametrize( "region,grid", [ ( Region(0, 0, 10, 10), [ (0, 0), ], ), ( Region(10, 10, 10, 10), ...
65
1,632
textual
tests/test_textlog.py
.py
from rich.text import Text from textual.widgets import RichLog async def test_make_renderable_expand_tabs(): # Regression test for https://github.com/Textualize/textual/issues/3007 text_log = RichLog() renderable = text_log._make_renderable("\tfoo") assert isinstance(renderable, Text) assert rend...
12
350
textual
tests/test_dom.py
.py
import pytest from textual.css.errors import StyleValueError from textual.dom import BadIdentifier, DOMNode def test_display_default(): node = DOMNode() assert node.display is True @pytest.mark.parametrize( "setter_value,style_value", [[True, "block"], [False, "none"], ["block", "block"], ["none", ...
283
6,918
textual
tests/test_placeholder.py
.py
import pytest from textual.widgets import Placeholder from textual.widgets._placeholder import InvalidPlaceholderVariant async def test_invalid_placeholder_variant(): with pytest.raises(InvalidPlaceholderVariant): Placeholder(variant="this is clearly not a valid variant!") async def test_invalid_reacti...
16
473
textual
tests/test_parser.py
.py
from textual._parser import Parser def test_read1(): class TestParser(Parser[str]): """A simple parser that reads a byte at a time from a stream.""" def parse(self, on_token): while True: data = yield self.read1() if not data: break ...
54
1,784
textual
tests/test_command.py
.py
from __future__ import annotations from typing import Iterable from textual.app import App, ComposeResult, SystemCommand from textual.containers import Grid from textual.screen import ModalScreen, Screen from textual.widgets import Button, Label class QuitScreen(ModalScreen[bool]): """Screen with a dialog to qu...
63
1,886
textual
tests/test_count_parameters.py
.py
from functools import partial from textual._callback import count_parameters def test_functions() -> None: """Test count parameters of functions.""" def foo(): ... def bar(a): ... def baz(a, b): ... # repeat to allow for caching for _ in range(3): assert count_parameters(foo) == 0 ...
58
1,377
textual
tests/test_widget_removing.py
.py
from textual.app import App, ComposeResult from textual.containers import Container, Vertical from textual.widgets import Button, Label, Static async def test_remove_single_widget(): """It should be possible to the only widget on a screen.""" async with App().run_test() as pilot: widget = Static() ...
228
8,442
textual
tests/test_demo.py
.py
from textual.demo.demo_app import DemoApp async def test_demo(): """Test the demo runs.""" # Test he demo can at least run. # This exists mainly to catch screw-ups that might effect only certain Python versions. app = DemoApp() async with app.run_test() as pilot: await pilot.pause(0.1)
11
317
textual
tests/test_xterm_parser.py
.py
import itertools import pytest from textual._xterm_parser import XTermParser from textual.events import ( Key, MouseDown, MouseMove, MouseScrollDown, MouseScrollLeft, MouseScrollRight, MouseScrollUp, MouseUp, Paste, ) from textual.messages import TerminalSupportsSynchronizedOutput ...
416
12,036
textual
tests/test_data_table.py
.py
from __future__ import annotations import pytest from rich.panel import Panel from rich.text import Text from textual._wait import wait_for_idle from textual.actions import SkipAction from textual.app import App, ComposeResult, RenderableType from textual.coordinate import Coordinate from textual.geometry import Offs...
1,492
52,375
textual
tests/test_styles_cache.py
.py
from __future__ import annotations from rich.segment import Segment from textual._styles_cache import StylesCache from textual.color import Color from textual.css.styles import Styles from textual.geometry import Region, Size from textual.strip import Strip def _extract_content(lines: list[Strip]) -> list[str]: ...
272
6,016
textual
tests/test_dynamic_bindings.py
.py
from __future__ import annotations from textual.app import App async def test_dynamic_disabled(): """Check we can dynamically disable bindings.""" actions = [] class DynamicApp(App): BINDINGS = [ ("a", "register('a')", "A"), ("b", "register('b')", "B"), ("c", ...
34
899
textual
tests/test_border_subtitle.py
.py
from textual.app import App, ComposeResult from textual.widget import Widget async def test_border_subtitle(): class BorderWidget(Widget): BORDER_TITLE = "foo" BORDER_SUBTITLE = "bar" class SimpleApp(App): def compose(self) -> ComposeResult: yield BorderWidget() empty...
19
518
textual
tests/test_easing.py
.py
""" Test the easing functions by sampling the range [0, 1] uniformly in 21 points. Then, a TypeScript script was used to sample all the original functions, the data was collected, and is here tested against the Python implementation. """ import pytest from textual._easing import EASING POINTS = [ 0.0, 0.05, ...
741
16,367
textual
tests/test_issue_4248.py
.py
"""Test https://github.com/Textualize/textual/issues/4248""" from textual.app import App, ComposeResult from textual.widgets import Label async def test_issue_4248() -> None: """Various forms of click parameters should be fine.""" bumps = 0 class ActionApp(App[None]): def compose(self) -> Compo...
43
1,608
textual
tests/test_path.py
.py
from __future__ import annotations from pathlib import Path import pytest from textual.app import App APP_DIR = Path(__file__).parent class RelativePathObjectApp(App[None]): CSS_PATH = Path("test.tcss") class RelativePathStrApp(App[None]): CSS_PATH = "test.tcss" class AbsolutePathObjectApp(App[None]):...
45
1,095
textual
tests/test_pilot.py
.py
from string import punctuation from typing import Type import pytest from textual import events, work from textual._on import on from textual.app import App, ComposeResult from textual.binding import Binding from textual.containers import Center, Middle from textual.css.errors import StylesheetError from textual.pilo...
453
15,523
textual
tests/test_rule.py
.py
import pytest from textual.widgets import Rule from textual.widgets.rule import InvalidLineStyle, InvalidRuleOrientation async def test_invalid_rule_orientation(): with pytest.raises(InvalidRuleOrientation): Rule(orientation="invalid orientation!") async def test_invalid_rule_line_style(): with pyt...
27
742
textual
tests/test_reactive.py
.py
from __future__ import annotations import asyncio import pytest from textual.app import App, ComposeResult from textual.message import Message from textual.message_pump import MessagePump from textual.reactive import Initialize, Reactive, TooManyComputesError, reactive, var from textual.widget import Widget OLD_VAL...
843
25,252
textual
tests/test_style_importance.py
.py
from textual.app import App, ComposeResult from textual.color import Color from textual.containers import Container from textual.css.scalar import ScalarOffset class StyleApp(App[None]): CSS = """ Container { border: round green !important; outline: round green !important; align: right...
103
3,501
textual
tests/test_validation.py
.py
from __future__ import annotations import pytest from textual.validation import ( URL, Failure, Function, Integer, Length, Number, Regex, ValidationResult, Validator, ) VALIDATOR = Function(lambda value: True) def test_ValidationResult_merge_successes(): results = [Validatio...
235
8,907
textual
tests/test_modal.py
.py
from __future__ import annotations from textual.app import App, ComposeResult from textual.containers import Grid from textual.screen import ModalScreen from textual.widgets import Button, Footer, Header, Label TEXT = """I must not fear. Fear is the mind-killer. Fear is the little-death that brings total obliteration...
100
2,563
textual
tests/test_selection.py
.py
import pytest from textual.app import App, ComposeResult from textual.containers import VerticalScroll from textual.geometry import Offset from textual.selection import Selection from textual.widgets import Static @pytest.mark.parametrize( "text,selection,expected", [ ("Hello", Selection(None, None),...
228
8,203
textual
tests/test_style_properties.py
.py
import pytest from rich.style import Style from textual.color import Color from textual.css.errors import StyleValueError from textual.css.styles import Styles def test_box_normalization(): """Check that none or hidden is normalized to empty string.""" styles = Styles() styles.border_left = ("none", "red...
33
1,120