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_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
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