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/test_filters.py
.py
from rich.color import Color as RichColor from rich.color import ColorType from rich.segment import Segment from rich.style import Style from rich.terminal_theme import MONOKAI from textual.color import Color from textual.filter import ANSIToTruecolor def test_ansi_to_truecolor_8_bit_dim(): """Test that converti...
30
906
textual
tests/test_style_inheritance.py
.py
from textual.app import App, ComposeResult from textual.widgets import Button, Static async def test_text_style_inheritance(): """Check that changes to text style are inherited in children.""" class FocusableThing(Static, can_focus=True): DEFAULT_CSS = """ FocusableThing { text-st...
38
1,099
textual
tests/test_auto_refresh.py
.py
import asyncio from time import time from textual.app import App from textual.pilot import Pilot class RefreshApp(App[float]): def __init__(self): self.count = 0 super().__init__() def on_mount(self): self.start = time() self.auto_refresh = 0.1 def automatic_refresh(self...
34
773
textual
tests/test_binding.py
.py
from string import ascii_lowercase import pytest from textual.app import App from textual.binding import ( Binding, BindingError, BindingsMap, InvalidBinding, NoBinding, ) from textual.screen import Screen BINDING1 = Binding("a,b", action="action1", description="description1") BINDING2 = Binding(...
140
3,992
textual
tests/test_slug.py
.py
import pytest from textual._slug import TrackedSlugs, slug, slug_for_tcss_id from textual.dom import check_identifiers @pytest.mark.xdist_group("group1") @pytest.mark.parametrize( "text, expected", [ ("test", "test"), ("Test", "test"), (" Test ", "test"), ("-test-", "-test-"),...
89
2,605
textual
tests/test_compositor_regions_to_spans.py
.py
from textual._compositor import Compositor from textual.geometry import Region def test_regions_to_ranges_no_regions(): assert list(Compositor._regions_to_spans([])) == [] def test_regions_to_ranges_single_region(): regions = [Region(0, 0, 3, 2)] assert list(Compositor._regions_to_spans(regions)) == [ ...
55
1,520
textual
tests/test_line_split.py
.py
from textual._line_split import line_split def test_split_string_to_lines_and_endings(): # Test with different line endings assert line_split("Hello\r\nWorld\n") == [("Hello", "\r\n"), ("World", "\n")] assert line_split("Hello\rWorld\r\n") == [("Hello", "\r"), ("World", "\r\n")] assert line_split("Hel...
27
849
textual
tests/test_signal.py
.py
import pytest from textual.app import App, ComposeResult from textual.signal import Signal, SignalError from textual.widgets import Label async def test_signal(): """Test signal subscribe""" called = 0 class TestLabel(Label): def on_mount(self) -> None: def signal_result(_): ...
111
3,159
textual
tests/test_color.py
.py
import pytest from rich.color import Color as RichColor from textual.color import Color, Gradient, Lab, lab_to_rgb, rgb_to_lab def test_rich_color(): """Check conversion to Rich color.""" assert Color(10, 20, 30, 1.0).rich_color == RichColor.from_rgb(10, 20, 30) assert Color.from_rich_color(RichColor.fro...
325
10,482
textual
tests/test_line_filter.py
.py
from rich.segment import Segment from rich.style import Style from textual.color import Color from textual.filter import DimFilter def test_dim_apply(): """Check dim filter changes color and resets dim attribute.""" dim_filter = DimFilter() segments = [Segment("Hello, World!", Style.parse("dim #ffffff ...
20
527
textual
tests/test_eta.py
.py
from textual.eta import ETA def test_basics() -> None: eta = ETA() eta.add_sample(1.0, 1.0) assert eta.first_sample == (0, 0) assert eta.last_sample == (1.0, 1.0) assert len(eta._samples) == 2 repr(eta) def test_speed() -> None: eta = ETA() # One sample is not enough to determine spe...
57
1,423
textual
tests/test_shutdown.py
.py
from textual.app import App from textual.containers import Horizontal from textual.widgets import Footer, Tree class TreeApp(App[None]): def compose(self): yield Horizontal(Tree("Dune")) yield Footer() async def test_shutdown(): # regression test for https://github.com/Textualize/textual/iss...
19
504
textual
tests/test_win_sleep.py
.py
import asyncio import time import sys import pytest from textual.app import App pytestmark = pytest.mark.skipif( sys.platform != "win32", reason="We only need to test this on Windows." ) def test_win_sleep_timer_is_cancellable(): """Regression test for https://github.com/Textualize/textual/issues/2711. ...
42
1,204
textual
tests/test_duration.py
.py
import pytest from textual._duration import DurationParseError, _duration_as_seconds def test_parse() -> None: assert _duration_as_seconds("30") == 30.0 assert _duration_as_seconds("30s") == 30.0 assert _duration_as_seconds("30000ms") == 30.0 assert _duration_as_seconds("0.5") == 0.5 assert _dura...
16
481
textual
tests/test_loop.py
.py
from textual._loop import loop_first, loop_first_last, loop_from_index, loop_last def test_loop_first(): assert list(loop_first([])) == [] iterable = loop_first(["apples", "oranges", "pears", "lemons"]) assert next(iterable) == (True, "apples") assert next(iterable) == (False, "oranges") assert ne...
66
1,784
textual
tests/test_border.py
.py
import pytest from rich.segment import Segment from rich.style import Style as RichStyle from rich.text import Text from textual._border import render_border_label, render_row from textual.content import Content from textual.style import Style from textual.widget import Widget def test_border_render_row(): style...
272
7,651
textual
tests/test_keys.py
.py
import pytest from textual.app import App from textual.binding import Binding from textual.keys import _character_to_key, format_key, key_to_character @pytest.mark.parametrize( "character,key", [ ("1", "1"), ("2", "2"), ("a", "a"), ("z", "z"), ("_", "underscore"), ...
79
2,171
textual
tests/test_widget.py
.py
from operator import attrgetter import pytest from textual import events from textual._node_list import DuplicateIds from textual.app import App, ComposeResult from textual.containers import Container, Vertical from textual.content import Content from textual.css.errors import StyleValueError from textual.css.query i...
769
22,998
textual
tests/test_freeze.py
.py
import pytest from textual.app import App from textual.screen import Screen from textual.widgets import Footer, Header, Input class MyScreen(Screen): def compose(self): yield Header() yield Input() yield Footer() class MyApp(App): def on_mount(self): self.install_screen(MySc...
27
616
textual
tests/test_message_pump.py
.py
import threading import pytest from textual._dispatch_key import dispatch_key from textual.app import App, ComposeResult from textual.errors import DuplicateKeyHandlers from textual.events import Key from textual.message import Message from textual.widget import Widget from textual.widgets import Button, Input, Label...
193
5,367
textual
tests/test_two_way_dict.py
.py
import pytest from textual._two_way_dict import TwoWayDict @pytest.fixture def two_way_dict(): return TwoWayDict( { 1: 10, 2: 20, 3: 30, } ) def test_get(two_way_dict): assert two_way_dict.get(1) == 10 def test_get_key(two_way_dict): assert two_...
46
871
textual
tests/test_overflow_change.py
.py
"""Regression test for #1616 https://github.com/Textualize/textual/issues/1616""" from textual.app import App from textual.containers import VerticalScroll async def test_overflow_change_updates_virtual_size_appropriately(): class MyApp(App): def compose(self): yield VerticalScroll() app...
36
1,049
textual
tests/test_tabs.py
.py
from __future__ import annotations import pytest from textual import on from textual.app import App, ComposeResult from textual.widgets import Tab, Tabs from textual.widgets._tabs import Underline async def test_tab_label(): """It should be possible to access a tab's label.""" assert Tab("Pilot").label_text...
513
16,823
textual
tests/test_on.py
.py
from __future__ import annotations from dataclasses import dataclass import pytest from textual import on from textual._on import OnDecoratorError from textual.app import App, ComposeResult from textual.events import Enter, Leave from textual.message import Message from textual.widget import Widget from textual.widg...
381
10,866
textual
tests/test_test_runner.py
.py
from textual import events from textual.app import App async def test_run_test() -> None: """Test the run_test context manager.""" keys_pressed: list[str] = [] class TestApp(App[str]): def on_key(self, event: events.Key) -> None: keys_pressed.append(event.key) app = TestApp() ...
24
779
textual
tests/test_markdown.py
.py
"""Unit tests for the Markdown widget.""" from __future__ import annotations from pathlib import Path from typing import Iterator import pytest from markdown_it.token import Token from rich.text import Span import textual.widgets._markdown as MD from textual import on from textual.app import App, ComposeResult from...
220
7,055
textual
tests/test_content.py
.py
from __future__ import annotations import pytest from rich.text import Text from textual.color import Color from textual.content import Content, Span from textual.style import Style from textual.visual import RenderOptions from textual.widget import Widget def test_blank(): """Check blank content.""" blank ...
590
17,878
textual
tests/test_suggestions.py
.py
import pytest from textual.suggestions import get_suggestion, get_suggestions @pytest.mark.parametrize( "word, possible_words, expected_result", ( ["background", ("background",), "background"], ["backgroundu", ("background",), "background"], ["bkgrund", ("background",), "background"],...
36
1,355
textual
tests/test_keymap.py
.py
from __future__ import annotations from typing import Any from textual.app import App, ComposeResult from textual.binding import Binding, Keymap from textual.dom import DOMNode from textual.widget import Widget from textual.widgets import Label class Counter(App[None]): BINDINGS = [ Binding(key="i,up", ...
220
6,410
textual
tests/test_immutable_sequence_view.py
.py
from typing import Sequence import pytest from textual._immutable_sequence_view import ImmutableSequenceView def wrap(source: Sequence[int]) -> ImmutableSequenceView[int]: """Wrap a sequence of integers inside an immutable sequence view.""" return ImmutableSequenceView[int](source) def test_empty_immutabl...
71
2,175
textual
tests/test_case.py
.py
from textual.case import camel_to_snake def test_camel_to_snake(): assert camel_to_snake("FooBar") == "foo_bar"
6
118
textual
tests/test_logger.py
.py
import inspect from typing import Any from textual import work from textual._log import LogGroup, LogVerbosity from textual.app import App async def test_log_from_worker() -> None: """Check that log calls from threaded workers call app._log""" log_messages: list[tuple] = [] class LogApp(App): ...
43
1,066
textual
tests/test_expand_tabs.py
.py
import pytest from textual.expand_tabs import expand_tabs_inline, get_tab_widths @pytest.mark.parametrize( "line, expanded_line", [ (" b ar ", " b ar "), ("\tbar", " bar"), ("\tbar\t", " bar "), ("\tr\t", " r "), ("1\tbar", "1 bar"), ("12\tbar", "1...
33
1,046
textual
tests/test_box_drawing.py
.py
import pytest from textual._box_drawing import combine_quads @pytest.mark.parametrize( "quad1, quad2, expected", [ ((0, 0, 0, 0), (0, 0, 0, 0), (0, 0, 0, 0)), ((0, 0, 0, 1), (0, 0, 0, 0), (0, 0, 0, 1)), ((0, 0, 0, 1), (0, 0, 0, 1), (0, 0, 0, 1)), ((0, 0, 0, 2), (0, 0, 0, 1), (...
26
905
textual
tests/test_screens.py
.py
from __future__ import annotations import asyncio import sys import threading import pytest from textual import work from textual.app import App, ComposeResult, ScreenStackError from textual.events import MouseMove from textual.geometry import Offset from textual.screen import Screen from textual.widgets import Butt...
626
18,384
textual
tests/test_masked_input.py
.py
from typing import Union import pytest from textual import on from textual.app import App, ComposeResult from textual.validation import Failure, ValidationResult from textual.widgets import MaskedInput InputEvent = Union[MaskedInput.Changed, MaskedInput.Submitted] class InputApp(App[None]): def __init__(self, ...
224
7,266
textual
tests/test_compositor.py
.py
from textual.app import App, ComposeResult from textual.containers import Container from textual.widgets import Static async def test_compositor_scroll_placements(): """Regression test for https://github.com/Textualize/textual/issues/5249 The Static should remain visible. """ class ScrollApp(App): ...
43
1,172
textual
tests/test_highlight.py
.py
import pytest from textual.content import Span from textual.highlight import guess_language, highlight def test_highlight() -> None: """Test simple application of highlight.""" import_this = highlight("import this", language="python") assert import_this.plain == "import this" print(import_this.spans)...
34
980
textual
tests/test_static.py
.py
from textual.content import Content from textual.widgets import Static async def test_content_property(): static = Static() assert static.content == "" static.content = "Foo" assert static.content == "Foo" assert isinstance(static.content, str) assert static.visual == "Foo" assert isinstan...
19
537
textual
tests/test_progress_bar.py
.py
import pytest from pytest import approx from rich.console import Console from rich.text import Text from textual.app import App, ComposeResult from textual.color import Gradient from textual.css.query import NoMatches from textual.renderables.bar import _apply_gradient from textual.widget import Widget from textual.wi...
206
4,613
textual
tests/test_focus.py
.py
from textual.app import App, ComposeResult from textual.containers import Container, ScrollableContainer, Vertical from textual.widget import Widget from textual.widgets import Button, Label from textual.widgets._placeholder import Placeholder class Focusable(Widget, can_focus=True): pass class NonFocusable(Wid...
551
17,436
textual
tests/test_gc.py
.py
import asyncio import gc import pytest from textual.app import App, ComposeResult from textual.containers import Vertical from textual.widgets import Footer, Header, Label def count_nodes() -> int: """Count number of references to DOMNodes.""" dom_nodes = [ obj for obj in gc.get_objects() ...
88
2,072
textual
tests/test_unmount.py
.py
from __future__ import annotations from textual import events from textual.app import App, ComposeResult from textual.containers import Container from textual.screen import Screen async def test_unmount() -> None: """Test unmount events are received in reverse DOM order.""" unmount_ids: list[str] = [] c...
55
1,646
textual
tests/test_containers.py
.py
"""Test basic functioning of some containers.""" from textual.app import App, ComposeResult from textual.containers import ( Center, Horizontal, HorizontalScroll, Middle, Vertical, VerticalScroll, ) from textual.widgets import Label async def test_horizontal_vs_horizontalscroll_scrolling(): ...
122
3,692
textual
tests/test_cache.py
.py
from __future__ import annotations, unicode_literals import pytest from textual.cache import FIFOCache, LRUCache def test_lru_cache(): cache = LRUCache(3) assert str(cache) == "<LRUCache size=0 maxsize=3 hits=0 misses=0>" # insert some values cache["foo"] = 1 cache["bar"] = 2 cache["baz"] ...
288
6,698
textual
tests/test_markup.py
.py
from __future__ import annotations import pytest from textual.content import Content, Span from textual.markup import MarkupError, to_content @pytest.mark.parametrize( ["markup", "content"], [ ("", Content("")), ("[", Content("[")), ("[]", Content("[]")), ("[ ", Content("[ ")...
200
5,507
textual
tests/test_query.py
.py
import pytest from textual.app import App, ComposeResult from textual.color import Color from textual.containers import Container from textual.css.query import ( DeclarationError, InvalidQueryFormat, NoMatches, TooManyMatches, WrongType, ) from textual.widget import Widget from textual.widgets impo...
405
12,655
textual
tests/test_widget_visibility.py
.py
from textual.app import App, ComposeResult from textual.widgets import Label async def test_hide() -> None: """Check that setting visibility produces Hide messages.""" # https://github.com/Textualize/textual/issues/3460 visibility: list[bool] = [] class ShowHideLabel(Label): def on_show(self)...
35
1,046
textual
tests/test_fuzzy.py
.py
from textual.content import Span from textual.fuzzy import Matcher from textual.style import Style def test_no_match(): """Check non matching score of zero.""" matcher = Matcher("x") assert matcher.match("foo") == 0 def test_match_single_group(): """Check that single groups rang higher.""" match...
40
1,092
textual
tests/test_style_parse.py
.py
import pytest from textual.color import Color from textual.style import Style @pytest.mark.parametrize( ["markup", "style"], [ ("", Style()), ( "b", Style(bold=True), ), ("i", Style(italic=True)), ("u", Style(underline=True)), ("r", Styl...
57
2,114
textual
tests/test_loading.py
.py
from textual.app import App, ComposeResult from textual.containers import VerticalScroll from textual.widgets import Label, Static class LoadingApp(App[None]): CSS = """ VerticalScroll { height: 20; } """ BINDINGS = [("l", "loading")] def compose(self) -> ComposeResult: with ...
56
1,509
textual
tests/test_widget_child_moving.py
.py
from __future__ import annotations import pytest from textual.app import App from textual.widget import Widget, WidgetError async def test_move_child_no_direction() -> None: """Test moving a widget in a child list.""" async with App().run_test() as pilot: child = Widget() await pilot.app.mou...
192
6,602
textual
tests/test_actions.py
.py
from __future__ import annotations from typing import Any import pytest from textual.actions import ActionError, parse @pytest.mark.parametrize( ("action_string", "expected_namespace", "expected_name", "expected_arguments"), [ ("spam", "", "spam", ()), ("hypothetical_action()", "", "hypothe...
91
2,694
textual
tests/option_list/test_option_messages.py
.py
"""Unit tests aimed at testing the option list messages.""" from __future__ import annotations from textual.app import App, ComposeResult from textual.geometry import Offset from textual.widgets import OptionList from textual.widgets.option_list import Option class OptionListApp(App[None]): """Test option list ...
113
4,303
textual
tests/option_list/test_option_list_mouse_hover.py
.py
"""Unit tests aimed at checking the OptionList mouse hover handing.""" from __future__ import annotations from textual.app import App, ComposeResult from textual.geometry import Offset from textual.widgets import Label, OptionList from textual.widgets.option_list import Option class OptionListApp(App[None]): ""...
66
2,703
textual
tests/option_list/test_option_list_disabled.py
.py
"""Unit tests for testing an option list's disabled facility.""" from __future__ import annotations import pytest from textual.app import App, ComposeResult from textual.widgets import OptionList from textual.widgets.option_list import Option, OptionDoesNotExist class OptionListApp(App[None]): """Test option l...
111
4,555
textual
tests/option_list/test_option_list_option_subclass.py
.py
"""Unit tests aimed at ensuring the option list option class can be subclassed.""" from __future__ import annotations from textual.app import App, ComposeResult from textual.widgets import OptionList from textual.widgets.option_list import Option class OptionWithExtras(Option): """An example subclass of a optio...
39
1,314
textual
tests/option_list/test_option_list_create.py
.py
"""Core option list unit tests, aimed at testing basic list creation.""" from __future__ import annotations import pytest from textual.app import App, ComposeResult from textual.widgets import OptionList from textual.widgets.option_list import DuplicateID, Option, OptionDoesNotExist class OptionListApp(App[None]):...
169
6,381
textual
tests/option_list/test_option_removal.py
.py
"""Test removing options from an option list.""" from __future__ import annotations import pytest from textual.app import App, ComposeResult from textual.geometry import Offset from textual.widgets import OptionList from textual.widgets.option_list import Option, OptionDoesNotExist class OptionListApp(App[None]): ...
113
4,429
textual
tests/option_list/test_option_prompt_replacement.py
.py
"""Test replacing options prompt from an option list.""" import pytest from textual.app import App, ComposeResult from textual.widgets import OptionList from textual.widgets.option_list import Option, OptionDoesNotExist class OptionListApp(App[None]): """Test option list application.""" def compose(self) ->...
73
3,245
textual
tests/option_list/test_option_list_id_stability.py
.py
"""Tests inspired by https://github.com/Textualize/textual/issues/4101""" from __future__ import annotations from textual.app import App, ComposeResult from textual.widgets import OptionList from textual.widgets.option_list import Option class OptionListApp(App[None]): """Test option list application.""" d...
23
704
textual
tests/option_list/test_option_list_mouse_click.py
.py
from __future__ import annotations from textual import on from textual.app import App, ComposeResult from textual.widgets import OptionList from textual.widgets.option_list import Option class OptionListApp(App[None]): messages: list[str] = [] def compose(self) -> ComposeResult: yield OptionList( ...
46
1,483
textual
tests/option_list/test_option_list_movement.py
.py
"""Test movement within an option list.""" from __future__ import annotations import pytest from textual.app import App, ComposeResult from textual.widgets import OptionList from textual.widgets.option_list import Option class OptionListApp(App[None]): """Test option list application.""" def compose(self)...
212
7,187
textual
tests/selection_list/test_selection_values.py
.py
"""Unit tests dealing with the tracking of selection list values.""" from __future__ import annotations from textual.app import App, ComposeResult from textual.widgets import SelectionList class SelectionListApp(App[None]): def __init__(self, default_state: bool = False) -> None: super().__init__() ...
83
3,216
textual
tests/selection_list/test_selection_click_checkbox.py
.py
"""See https://github.com/Textualize/textual/pull/2930 for the introduction of these tests.""" from textual import on from textual.app import App, ComposeResult from textual.geometry import Offset from textual.widgets import SelectionList class SelectionListApp(App[None]): """Test selection list application.""" ...
43
1,520
textual
tests/selection_list/test_selection_messages.py
.py
"""Unit tests aimed at testing the selection list messages. Note that these tests only cover a subset of the public API of this widget. The bulk of the API is inherited from OptionList, and as such there are comprehensive tests for that. These tests simply cover the parts of the API that have been modified by the chil...
228
8,131
textual
tests/selection_list/test_selection_list_create.py
.py
"""Core selection list unit tests, aimed at testing basic list creation. Note that the vast majority of the API *isn't* tested in here as `SelectionList` inherits from `OptionList` and so that would be duplicated effort. Instead these tests aim to just test the things that have been changed or wrapped in some way. """...
125
4,831
textual
tests/selection_list/test_over_wide_selections.py
.py
"""See https://github.com/Textualize/textual/issues/2900 for the reason behind these tests.""" from textual.app import App, ComposeResult from textual.widgets import SelectionList class SelectionListApp(App[None]): """Test selection list application.""" CSS = """ OptionList { width: 20; } ...
30
821
textual
tests/animations/test_progress_bar_animation.py
.py
""" Tests for the indeterminate progress bar animation, which is considered a basic animation. (An animation that also plays on the level BASIC.) """ from textual.app import App, ComposeResult from textual.widgets import ProgressBar from textual.widgets._progress_bar import Bar class ProgressBarApp(App[None]): d...
48
1,611
textual
tests/animations/test_environment_variable.py
.py
import pytest from textual import constants from textual.app import App from textual.constants import _get_textual_animations @pytest.mark.parametrize( ["env_variable", "value"], [ ("", "full"), # default ("FULL", "full"), ("BASIC", "basic"), ("NONE", "none"), ("garba...
33
968
textual
tests/animations/test_scrolling_animation.py
.py
""" Tests for scrolling animations, which are considered a basic animation. (An animation that also plays on the level BASIC.) """ from textual.app import App, ComposeResult from textual.containers import VerticalScroll from textual.widgets import Label class TallApp(App[None]): def compose(self) -> ComposeResul...
70
2,414
textual
tests/animations/test_switch_animation.py
.py
""" Tests for the switch toggle animation, which is considered a basic animation. (An animation that also plays on the level BASIC.) """ from textual.app import App, ComposeResult from textual.widgets import Switch class SwitchApp(App[None]): def compose(self) -> ComposeResult: yield Switch() async def...
70
2,369
textual
tests/animations/test_tabs_underline_animation.py
.py
""" Tests for the tabs underline animation, which is considered a basic animation. (An animation that also plays on the level BASIC.) """ from textual.app import App, ComposeResult from textual.widgets import Label, TabbedContent, Tabs class TabbedContentApp(App[None]): def compose(self) -> ComposeResult: ...
63
1,983
textual
tests/animations/test_disabling_animations.py
.py
""" Test that generic animations can be disabled. """ from textual.app import App, ComposeResult from textual.color import Color from textual.widgets import Label class SingleLabelApp(App[None]): """Single label whose background colour we'll animate.""" CSS = """ Label { background: red;...
164
5,665
textual
tests/animations/test_loading_indicator_animation.py
.py
""" Tests for the loading indicator animation, which is considered a basic animation. (An animation that also plays on the level BASIC.) """ from textual.app import App async def test_loading_indicator_is_not_static_on_full() -> None: """The loading indicator doesn't fall back to the static render on FULL.""" ...
43
1,362
textual
tests/text_area/test_history.py
.py
from __future__ import annotations import dataclasses import pytest from textual.app import App, ComposeResult from textual.events import Paste from textual.widgets import TextArea from textual.widgets.text_area import EditHistory, Selection MAX_CHECKPOINTS = 5 SIMPLE_TEXT = """\ ABCDE FGHIJ KLMNO PQRST UVWXY Z """...
402
12,929
textual
tests/text_area/test_selection_bindings.py
.py
import pytest from textual.app import App, ComposeResult from textual.geometry import Offset from textual.widgets import TextArea from textual.widgets.text_area import Selection TEXT = """I must not fear. Fear is the mind-killer. Fear is the little-death that brings total obliteration. I will face my fear. """ clas...
312
11,219
textual
tests/text_area/test_setting_themes.py
.py
import pytest from textual._text_area_theme import TextAreaTheme from textual.app import App, ComposeResult from textual.widgets import TextArea from textual.widgets._text_area import ThemeDoesNotExist class TextAreaApp(App[None]): def compose(self) -> ComposeResult: yield TextArea("print('hello')", lang...
57
1,561
textual
tests/text_area/test_textarea_cut_copy_paste.py
.py
from textual.app import App, ComposeResult from textual.widgets import TextArea class TextAreaApp(App): def compose(self) -> ComposeResult: yield TextArea() async def test_cut(): """Check that cut removes text and places it in the clipboard.""" app = TextAreaApp() async with app.run_test() a...
53
1,780
textual
tests/text_area/test_code_editor.py
.py
import inspect from textual.widgets import TextArea def test_code_editor_parameters_kept_up_to_date(): """Meta test to ensure the `TextArea.code_editor` convenience constructor is kept up to date with changes to the `TextArea.__init__` parameters. """ text_area_params = inspect.signature(TextArea.__i...
19
734
textual
tests/text_area/test_messages.py
.py
from typing import List from textual import on from textual.app import App, ComposeResult from textual.events import Event from textual.message import Message from textual.widgets import TextArea class TextAreaApp(App): def __init__(self): super().__init__() self.messages = [] @on(TextArea.C...
105
3,152
textual
tests/text_area/test_languages.py
.py
import pytest from textual.app import App, ComposeResult from textual.widgets import TextArea from textual.widgets.text_area import LanguageDoesNotExist class TextAreaApp(App): def compose(self) -> ComposeResult: yield TextArea("print('hello')", language="python") async def test_setting_builtin_languag...
96
2,801
textual
tests/text_area/test_edit_via_api.py
.py
"""Tests editing the document using the API (replace etc.) The tests in this module directly call the edit APIs on the TextArea rather than going via bindings. Note that more extensive testing for editing is done at the Document level. """ import pytest from textual.app import App, ComposeResult from textual.widget...
572
18,163
textual
tests/text_area/test_selection.py
.py
import pytest from textual.app import App, ComposeResult from textual.widgets import TextArea from textual.widgets.text_area import Selection TEXT = """I must not fear. Fear is the mind-killer. Fear is the little-death that brings total obliteration. I will face my fear. """ class TextAreaApp(App): def compose(...
356
10,670
textual
tests/text_area/test_edit_via_bindings.py
.py
"""Tests some edits using the keyboard. All tests in this module should press keys on the keyboard which edit the document, and check that the document content is updated as expected, as well as the cursor location. Note that more extensive testing for editing is done at the Document level. """ import pytest from t...
632
19,915
textual
tests/text_area/test_escape_binding.py
.py
from textual.app import App, ComposeResult from textual.screen import ModalScreen from textual.widgets import Button, TextArea class TextAreaDialog(ModalScreen): BINDINGS = [("escape", "dismiss")] def compose(self) -> ComposeResult: yield TextArea( tab_behavior="focus", # the default ...
56
1,880
textual
tests/text_area/test_issue_4301.py
.py
from itertools import product import pytest from textual.app import App, ComposeResult from textual.widgets import TextArea from textual.widgets.text_area import Selection TEST_TEXT = "\n".join(f"01234567890 - {n}" for n in range(10)) TEST_SELECTED_TEXT = "567890 - 0\n01234567890 - 1\n01234" class TextAreaApp(App[...
39
1,285
textual
tests/suggester/test_suggest_from_list.py
.py
from __future__ import annotations import pytest from textual.dom import DOMNode from textual.suggester import SuggestFromList, SuggestionReady countries = ["England", "Portugal", "Scotland", "portugal", "PORTUGAL"] class LogListNode(DOMNode): def __init__(self, log_list: list[tuple[str, str]]) -> None: ...
56
1,470
textual
tests/suggester/test_suggester.py
.py
from __future__ import annotations import pytest from textual.dom import DOMNode from textual.suggester import Suggester, SuggestionReady class FillSuggester(Suggester): async def get_suggestion(self, value: str): if len(value) <= 10: return f"{value:x<10}" class LogListNode(DOMNode): ...
112
3,211
textual
tests/suggester/test_input_suggestions.py
.py
import string import pytest from textual.app import App, ComposeResult from textual.suggester import SuggestFromList from textual.widgets import Input class SuggestionsApp(App[ComposeResult]): def __init__(self, suggestions): self.suggestions = suggestions self.input = Input(suggester=SuggestFro...
102
3,050
textual
tests/document/test_document.py
.py
import pytest from textual.widgets.text_area import Document TEXT = """I must not fear. Fear is the mind-killer.""" TEXT_NEWLINE = TEXT + "\n" TEXT_WINDOWS = TEXT.replace("\n", "\r\n") TEXT_WINDOWS_NEWLINE = TEXT_NEWLINE.replace("\n", "\r\n") @pytest.mark.parametrize( "text", [TEXT, TEXT_NEWLINE, TEXT_WINDOWS,...
153
4,548
textual
tests/document/test_wrapped_document.py
.py
import pytest from textual.document._document import Document from textual.document._wrapped_document import WrappedDocument from textual.geometry import Offset SIMPLE_TEXT = "123 4567\n12345\n123456789\n" def test_wrap(): document = Document(SIMPLE_TEXT) wrapped_document = WrappedDocument(document, width=4...
205
5,879
textual
tests/document/test_document_navigator.py
.py
import pytest from textual.document._document import Document from textual.document._document_navigator import DocumentNavigator from textual.document._wrapped_document import WrappedDocument TEXT = """\ 01 3456 01234""" # wrapped width = 4: # line_index | wrapped_lines # 0 | 01_ # | 3456 # 1 | 0123 # | 4 def...
95
2,122
textual
tests/document/test_document_delete.py
.py
import pytest from textual.widgets.text_area import Document, EditResult TEXT = """I must not fear. Fear is the mind-killer. I forgot the rest of the quote. Sorry Will.""" @pytest.fixture def document(): document = Document(TEXT) return document def test_delete_single_character(document): replace_resu...
147
4,306
textual
tests/document/test_document_insert.py
.py
from textual.widgets.text_area import Document TEXT = """I must not fear. Fear is the mind-killer.""" def test_insert_no_newlines(): document = Document(TEXT) document.replace_range((0, 1), (0, 1), " really") assert document.lines == [ "I really must not fear.", "Fear is the mind-killer."...
108
2,958
textual
tests/toggles/test_radioset.py
.py
from __future__ import annotations from textual.app import App, ComposeResult from textual.widgets import RadioButton, RadioSet class RadioSetApp(App[None]): def __init__(self): super().__init__() self.events_received = [] def compose(self) -> ComposeResult: with RadioSet(id="from_bu...
184
6,980
textual
tests/toggles/test_checkbox.py
.py
from __future__ import annotations from textual.app import App, ComposeResult from textual.widgets import Checkbox class CheckboxApp(App[None]): def __init__(self): super().__init__() self.events_received = [] def compose(self) -> ComposeResult: yield Checkbox("Test", id="cb1") ...
52
1,707
textual
tests/toggles/test_radiobutton.py
.py
from __future__ import annotations from textual.app import App, ComposeResult from textual.widgets import RadioButton class RadioButtonApp(App[None]): def __init__(self): super().__init__() self.events_received = [] def compose(self) -> ComposeResult: yield RadioButton("Test", id="rb...
64
1,955
textual
tests/toggles/test_labels.py
.py
"""Test that setting a toggle button's label has the desired effect.""" from textual.app import App, ComposeResult from textual.content import Content from textual.widgets import Checkbox, RadioButton, RadioSet class LabelChangeApp(App[None]): def compose(self) -> ComposeResult: yield Checkbox("Before") ...
36
1,431
textual
tests/layouts/test_factory.py
.py
import pytest from textual.layouts.factory import MissingLayout, get_layout from textual.layouts.vertical import VerticalLayout def test_get_layout_valid_layout(): layout = get_layout("vertical") assert type(layout) is VerticalLayout def test_get_layout_invalid_layout(): with pytest.raises(MissingLayou...
15
354