mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
Add isort pre-commit hook, sort imports in src and test directories
This commit is contained in:
@@ -2,17 +2,17 @@ import pytest
|
||||
|
||||
from tests.utilities.render import render
|
||||
from textual.css._help_text import (
|
||||
spacing_wrong_number_of_values_help_text,
|
||||
spacing_invalid_value_help_text,
|
||||
scalar_help_text,
|
||||
string_enum_help_text,
|
||||
color_property_help_text,
|
||||
border_property_help_text,
|
||||
layout_property_help_text,
|
||||
fractional_property_help_text,
|
||||
offset_property_help_text,
|
||||
align_help_text,
|
||||
border_property_help_text,
|
||||
color_property_help_text,
|
||||
fractional_property_help_text,
|
||||
layout_property_help_text,
|
||||
offset_property_help_text,
|
||||
offset_single_axis_help_text,
|
||||
scalar_help_text,
|
||||
spacing_invalid_value_help_text,
|
||||
spacing_wrong_number_of_values_help_text,
|
||||
string_enum_help_text,
|
||||
style_flags_property_help_text,
|
||||
)
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ from textual.css.parse import substitute_references
|
||||
from textual.css.scalar import Scalar, Unit
|
||||
from textual.css.stylesheet import Stylesheet, StylesheetParseError
|
||||
from textual.css.tokenize import tokenize
|
||||
from textual.css.tokenizer import Token, ReferencedBy
|
||||
from textual.css.tokenizer import ReferencedBy, Token
|
||||
from textual.css.transition import Transition
|
||||
from textual.geometry import Spacing
|
||||
from textual.layouts.vertical import VerticalLayout
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
from decimal import Decimal
|
||||
|
||||
import pytest
|
||||
|
||||
from rich.style import Style
|
||||
|
||||
from textual.color import Color
|
||||
from textual.css.errors import StyleValueError
|
||||
from textual.css.scalar import Scalar, Unit
|
||||
from textual.css.styles import Styles, RenderStyles
|
||||
from textual.css.styles import RenderStyles, Styles
|
||||
from textual.dom import DOMNode
|
||||
from textual.widget import Widget
|
||||
|
||||
|
||||
@@ -11,6 +11,4 @@ _WINDOWS = sys.platform == "win32"
|
||||
# and the error messages suggest the event loop is being shutdown before async fixture
|
||||
# teardown code has finished running. These are very rare, but are much more of an issue on
|
||||
# CI since they can delay builds that have passed locally.
|
||||
pytestmark = pytest.mark.skipif(
|
||||
_MACOS_CI or _WINDOWS, reason="Issue #411"
|
||||
)
|
||||
pytestmark = pytest.mark.skipif(_MACOS_CI or _WINDOWS, reason="Issue #411")
|
||||
|
||||
@@ -30,7 +30,6 @@ async def test_devtools_client_is_connected(devtools):
|
||||
|
||||
@time_machine.travel(datetime.utcfromtimestamp(TIMESTAMP))
|
||||
async def test_devtools_log_places_encodes_and_queues_message(devtools):
|
||||
|
||||
await devtools._stop_log_queue_processing()
|
||||
devtools.log(DevtoolsLog("Hello, world!", CALLER))
|
||||
queued_log = await devtools.log_queue.get()
|
||||
|
||||
@@ -5,7 +5,6 @@ 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",
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
from rich.console import Console
|
||||
|
||||
from textual.app import App
|
||||
from textual.widgets import Input
|
||||
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
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.geometry import Size
|
||||
from textual.widget import Widget
|
||||
|
||||
|
||||
LAYOUTS = [GridLayout, HorizontalLayout, VerticalLayout]
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import pytest
|
||||
|
||||
from textual.layouts.factory import get_layout, MissingLayout
|
||||
from textual.layouts.factory import MissingLayout, get_layout
|
||||
from textual.layouts.vertical import VerticalLayout
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from textual.app import App, ComposeResult
|
||||
from textual.widgets import ListView, ListItem, Label
|
||||
from textual.widgets import Label, ListItem, ListView
|
||||
|
||||
|
||||
class MyListView(ListView):
|
||||
|
||||
@@ -20,22 +20,35 @@ def test_sparkline_two_values_min_max():
|
||||
|
||||
|
||||
def test_sparkline_expand_data_to_width():
|
||||
assert render(Sparkline([2, 4],
|
||||
width=4)) == f"{GREEN}▁{STOP}{GREEN}▁{STOP}{RED}█{STOP}{RED}█{STOP}"
|
||||
assert (
|
||||
render(Sparkline([2, 4], width=4))
|
||||
== f"{GREEN}▁{STOP}{GREEN}▁{STOP}{RED}█{STOP}{RED}█{STOP}"
|
||||
)
|
||||
|
||||
|
||||
def test_sparkline_expand_data_to_width_non_divisible():
|
||||
assert render(Sparkline([2, 4], width=3)) == f"{GREEN}▁{STOP}{GREEN}▁{STOP}{RED}█{STOP}"
|
||||
assert (
|
||||
render(Sparkline([2, 4], width=3))
|
||||
== f"{GREEN}▁{STOP}{GREEN}▁{STOP}{RED}█{STOP}"
|
||||
)
|
||||
|
||||
|
||||
def test_sparkline_shrink_data_to_width():
|
||||
assert render(Sparkline([2, 2, 4, 4, 6, 6], width=3)) == f"{GREEN}▁{STOP}{BLENDED}▄{STOP}{RED}█{STOP}"
|
||||
assert (
|
||||
render(Sparkline([2, 2, 4, 4, 6, 6], width=3))
|
||||
== f"{GREEN}▁{STOP}{BLENDED}▄{STOP}{RED}█{STOP}"
|
||||
)
|
||||
|
||||
|
||||
def test_sparkline_shrink_data_to_width_non_divisible():
|
||||
assert render(
|
||||
Sparkline([1, 2, 3, 4, 5], width=3, summary_function=min)) == f"{GREEN}▁{STOP}{BLENDED}▄{STOP}{RED}█{STOP}"
|
||||
assert (
|
||||
render(Sparkline([1, 2, 3, 4, 5], width=3, summary_function=min))
|
||||
== f"{GREEN}▁{STOP}{BLENDED}▄{STOP}{RED}█{STOP}"
|
||||
)
|
||||
|
||||
|
||||
def test_sparkline_color_blend():
|
||||
assert render(Sparkline([1, 2, 3], width=3)) == f"{GREEN}▁{STOP}{BLENDED}▄{STOP}{RED}█{STOP}"
|
||||
assert (
|
||||
render(Sparkline([1, 2, 3], width=3))
|
||||
== f"{GREEN}▁{STOP}{BLENDED}▄{STOP}{RED}█{STOP}"
|
||||
)
|
||||
|
||||
@@ -14,7 +14,7 @@ def text():
|
||||
|
||||
def test_simple_text_opacity(text):
|
||||
blended_red_on_green = "\x1b[38;2;127;127;0;48;2;0;255;0m"
|
||||
assert render(TextOpacity(text, opacity=.5)) == (
|
||||
assert render(TextOpacity(text, opacity=0.5)) == (
|
||||
f"{blended_red_on_green}Hello, world!{STOP}"
|
||||
)
|
||||
|
||||
@@ -31,19 +31,21 @@ def test_text_opacity_value_of_one_noop(text):
|
||||
|
||||
def test_ansi_colors_noop():
|
||||
ansi_colored_text = Text("Hello, world!", style="red on green", end="")
|
||||
assert render(TextOpacity(ansi_colored_text, opacity=.5)) == render(ansi_colored_text)
|
||||
assert render(TextOpacity(ansi_colored_text, opacity=0.5)) == render(
|
||||
ansi_colored_text
|
||||
)
|
||||
|
||||
|
||||
def test_text_opacity_no_style_noop():
|
||||
text_no_style = Text("Hello, world!", end="")
|
||||
assert render(TextOpacity(text_no_style, opacity=.2)) == render(text_no_style)
|
||||
assert render(TextOpacity(text_no_style, opacity=0.2)) == render(text_no_style)
|
||||
|
||||
|
||||
def test_text_opacity_only_fg_noop():
|
||||
text_only_fg = Text("Hello, world!", style="#ff0000", end="")
|
||||
assert render(TextOpacity(text_only_fg, opacity=.5)) == render(text_only_fg)
|
||||
assert render(TextOpacity(text_only_fg, opacity=0.5)) == render(text_only_fg)
|
||||
|
||||
|
||||
def test_text_opacity_only_bg_noop():
|
||||
text_only_bg = Text("Hello, world!", style="on #ff0000", end="")
|
||||
assert render(TextOpacity(text_only_bg, opacity=.5)) == render(text_only_bg)
|
||||
assert render(TextOpacity(text_only_bg, opacity=0.5)) == render(text_only_bg)
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
from unittest.mock import create_autospec
|
||||
|
||||
from rich.console import Console
|
||||
from rich.console import ConsoleOptions
|
||||
from rich.console import Console, ConsoleOptions
|
||||
from rich.text import Text
|
||||
|
||||
from tests.utilities.render import render
|
||||
@@ -21,16 +20,12 @@ def test_no_highlight():
|
||||
|
||||
def test_highlight_from_zero():
|
||||
bar = UnderlineBar(highlight_range=(0, 2.5), width=6)
|
||||
assert render(bar) == (
|
||||
f"{MAGENTA}━━{STOP}{MAGENTA}╸{STOP}{GREY}━━━{STOP}"
|
||||
)
|
||||
assert render(bar) == (f"{MAGENTA}━━{STOP}{MAGENTA}╸{STOP}{GREY}━━━{STOP}")
|
||||
|
||||
|
||||
def test_highlight_from_zero_point_five():
|
||||
bar = UnderlineBar(highlight_range=(0.5, 2), width=6)
|
||||
assert render(bar) == (
|
||||
f"{MAGENTA}╺━{STOP}{GREY}╺{STOP}{GREY}━━━{STOP}"
|
||||
)
|
||||
assert render(bar) == (f"{MAGENTA}╺━{STOP}{GREY}╺{STOP}{GREY}━━━{STOP}")
|
||||
|
||||
|
||||
def test_highlight_middle():
|
||||
@@ -47,10 +42,7 @@ def test_highlight_middle():
|
||||
def test_highlight_half_start():
|
||||
bar = UnderlineBar(highlight_range=(2.5, 4), width=6)
|
||||
assert render(bar) == (
|
||||
f"{GREY}━━{STOP}"
|
||||
f"{MAGENTA}╺━{STOP}"
|
||||
f"{GREY}╺{STOP}"
|
||||
f"{GREY}━{STOP}"
|
||||
f"{GREY}━━{STOP}" f"{MAGENTA}╺━{STOP}" f"{GREY}╺{STOP}" f"{GREY}━{STOP}"
|
||||
)
|
||||
|
||||
|
||||
@@ -68,42 +60,30 @@ def test_highlight_half_end():
|
||||
def test_highlight_half_start_and_half_end():
|
||||
bar = UnderlineBar(highlight_range=(2.5, 4.5), width=6)
|
||||
assert render(bar) == (
|
||||
f"{GREY}━━{STOP}"
|
||||
f"{MAGENTA}╺━{STOP}"
|
||||
f"{MAGENTA}╸{STOP}"
|
||||
f"{GREY}━{STOP}"
|
||||
f"{GREY}━━{STOP}" f"{MAGENTA}╺━{STOP}" f"{MAGENTA}╸{STOP}" f"{GREY}━{STOP}"
|
||||
)
|
||||
|
||||
|
||||
def test_highlight_to_near_end():
|
||||
bar = UnderlineBar(highlight_range=(3, 5.5), width=6)
|
||||
assert render(bar) == (
|
||||
f"{GREY}━━{STOP}"
|
||||
f"{GREY}╸{STOP}"
|
||||
f"{MAGENTA}━━{STOP}"
|
||||
f"{MAGENTA}╸{STOP}"
|
||||
f"{GREY}━━{STOP}" f"{GREY}╸{STOP}" f"{MAGENTA}━━{STOP}" f"{MAGENTA}╸{STOP}"
|
||||
)
|
||||
|
||||
|
||||
def test_highlight_to_end():
|
||||
bar = UnderlineBar(highlight_range=(3, 6), width=6)
|
||||
assert render(bar) == (
|
||||
f"{GREY}━━{STOP}{GREY}╸{STOP}{MAGENTA}━━━{STOP}"
|
||||
)
|
||||
assert render(bar) == (f"{GREY}━━{STOP}{GREY}╸{STOP}{MAGENTA}━━━{STOP}")
|
||||
|
||||
|
||||
def test_highlight_out_of_bounds_start():
|
||||
bar = UnderlineBar(highlight_range=(-2, 3), width=6)
|
||||
assert render(bar) == (
|
||||
f"{MAGENTA}━━━{STOP}{GREY}╺{STOP}{GREY}━━{STOP}"
|
||||
)
|
||||
assert render(bar) == (f"{MAGENTA}━━━{STOP}{GREY}╺{STOP}{GREY}━━{STOP}")
|
||||
|
||||
|
||||
def test_highlight_out_of_bounds_end():
|
||||
bar = UnderlineBar(highlight_range=(3, 9), width=6)
|
||||
assert render(bar) == (
|
||||
f"{GREY}━━{STOP}{GREY}╸{STOP}{MAGENTA}━━━{STOP}"
|
||||
)
|
||||
assert render(bar) == (f"{GREY}━━{STOP}{GREY}╸{STOP}{MAGENTA}━━━{STOP}")
|
||||
|
||||
|
||||
def test_highlight_full_range_out_of_bounds_end():
|
||||
@@ -117,7 +97,9 @@ def test_highlight_full_range_out_of_bounds_start():
|
||||
|
||||
|
||||
def test_custom_styles():
|
||||
bar = UnderlineBar(highlight_range=(2, 4), highlight_style="red", background_style="green", width=6)
|
||||
bar = UnderlineBar(
|
||||
highlight_range=(2, 4), highlight_style="red", background_style="green", width=6
|
||||
)
|
||||
assert render(bar) == (
|
||||
f"{GREEN}━{STOP}"
|
||||
f"{GREEN}╸{STOP}"
|
||||
@@ -128,7 +110,9 @@ def test_custom_styles():
|
||||
|
||||
|
||||
def test_clickable_ranges():
|
||||
bar = UnderlineBar(highlight_range=(0, 1), width=6, clickable_ranges={"foo": (0, 2), "bar": (4, 5)})
|
||||
bar = UnderlineBar(
|
||||
highlight_range=(0, 1), width=6, clickable_ranges={"foo": (0, 2), "bar": (4, 5)}
|
||||
)
|
||||
|
||||
console = create_autospec(Console)
|
||||
options = create_autospec(ConsoleOptions)
|
||||
@@ -136,8 +120,8 @@ def test_clickable_ranges():
|
||||
|
||||
start, end, style = text.spans[-2]
|
||||
assert (start, end) == (0, 2)
|
||||
assert style.meta == {'@click': "range_clicked('foo')"}
|
||||
assert style.meta == {"@click": "range_clicked('foo')"}
|
||||
|
||||
start, end, style = text.spans[-1]
|
||||
assert (start, end) == (4, 5)
|
||||
assert style.meta == {'@click': "range_clicked('bar')"}
|
||||
assert style.meta == {"@click": "range_clicked('bar')"}
|
||||
|
||||
@@ -6,7 +6,7 @@ from unittest.mock import Mock
|
||||
import pytest
|
||||
|
||||
from textual._animator import Animator, SimpleAnimation
|
||||
from textual._easing import EASING, DEFAULT_EASING
|
||||
from textual._easing import DEFAULT_EASING, EASING
|
||||
|
||||
|
||||
class Animatable:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import pytest
|
||||
|
||||
from textual._arrange import arrange, TOP_Z
|
||||
from textual._arrange import TOP_Z, arrange
|
||||
from textual._layout import WidgetPlacement
|
||||
from textual.geometry import Region, Size, Spacing
|
||||
from textual.widget import Widget
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
from textual import events
|
||||
from textual.app import App
|
||||
from textual.pilot import Pilot
|
||||
from textual import events
|
||||
|
||||
|
||||
def test_auto_pilot() -> None:
|
||||
|
||||
keys_pressed: list[str] = []
|
||||
|
||||
class TestApp(App):
|
||||
@@ -12,7 +11,6 @@ def test_auto_pilot() -> None:
|
||||
keys_pressed.append(event.key)
|
||||
|
||||
async def auto_pilot(pilot: Pilot) -> None:
|
||||
|
||||
await pilot.press("tab", *"foo")
|
||||
await pilot.exit("bar")
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ from string import ascii_lowercase
|
||||
import pytest
|
||||
|
||||
from textual.app import App
|
||||
from textual.binding import Bindings, Binding, BindingError, NoBinding, InvalidBinding
|
||||
from textual.binding import Binding, BindingError, Bindings, InvalidBinding, NoBinding
|
||||
|
||||
BINDING1 = Binding("a,b", action="action1", description="description1")
|
||||
BINDING2 = Binding("c", action="action2", description="description2")
|
||||
|
||||
@@ -5,7 +5,6 @@ from textual._border import render_row
|
||||
|
||||
|
||||
def test_border_render_row():
|
||||
|
||||
style = Style.parse("red")
|
||||
row = (Segment("┏", style), Segment("━", style), Segment("┓", style))
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
from __future__ import annotations
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import annotations, unicode_literals
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import asyncio
|
||||
|
||||
from textual.app import App
|
||||
|
||||
|
||||
|
||||
@@ -43,7 +43,6 @@ def test_rgb():
|
||||
|
||||
|
||||
def test_hls():
|
||||
|
||||
red = Color(200, 20, 32)
|
||||
print(red.hsl)
|
||||
assert red.hsl == pytest.approx(
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
from threading import Thread
|
||||
|
||||
import pytest
|
||||
|
||||
from threading import Thread
|
||||
from textual.app import App, ComposeResult
|
||||
from textual.widgets import TextLog
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import pytest
|
||||
|
||||
from textual.css.errors import StyleValueError
|
||||
from textual.dom import DOMNode, BadIdentifier
|
||||
from textual.dom import BadIdentifier, DOMNode
|
||||
|
||||
|
||||
def test_display_default():
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import pytest
|
||||
|
||||
from textual.geometry import clamp, Offset, Size, Region, Spacing
|
||||
from textual.geometry import Offset, Region, Size, Spacing, clamp
|
||||
|
||||
|
||||
def test_dimensions_region():
|
||||
@@ -299,6 +299,7 @@ def test_size_line_range():
|
||||
assert Size(20, 0).line_range == range(0)
|
||||
assert Size(0, 20).line_range == range(20)
|
||||
|
||||
|
||||
def test_region_x_extents():
|
||||
assert Region(5, 10, 20, 30).column_span == (5, 25)
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
from typing import Sequence
|
||||
|
||||
import pytest
|
||||
|
||||
from typing import Sequence
|
||||
from textual._immutable_sequence_view import ImmutableSequenceView
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from textual._loop import loop_first, loop_last, loop_first_last
|
||||
from textual._loop import loop_first, loop_first_last, loop_last
|
||||
|
||||
|
||||
def test_loop_first():
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import pytest
|
||||
|
||||
from textual.widget import Widget
|
||||
from textual._node_list import NodeList
|
||||
from textual.widget import Widget
|
||||
|
||||
|
||||
def test_empty_list():
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
"""Regression test for #1616 https://github.com/Textualize/textual/issues/1616"""
|
||||
import pytest
|
||||
|
||||
|
||||
from textual.app import App
|
||||
from textual.containers import Vertical
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from textual.app import App
|
||||
from textual import events
|
||||
from textual.app import App
|
||||
|
||||
|
||||
async def test_paste_app():
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
from textual.app import App
|
||||
|
||||
@@ -2,8 +2,8 @@ import pytest
|
||||
|
||||
from textual.app import App, ComposeResult
|
||||
from textual.containers import Container
|
||||
from textual.css.query import InvalidQueryFormat, NoMatches, TooManyMatches, WrongType
|
||||
from textual.widget import Widget
|
||||
from textual.css.query import InvalidQueryFormat, WrongType, NoMatches, TooManyMatches
|
||||
|
||||
|
||||
def test_query():
|
||||
|
||||
@@ -259,7 +259,6 @@ async def test_reactive_method_call_order():
|
||||
|
||||
|
||||
async def test_premature_reactive_call():
|
||||
|
||||
watcher_called = False
|
||||
|
||||
class BrokenWidget(Widget):
|
||||
@@ -335,7 +334,6 @@ async def test_watch_compute():
|
||||
watch_called: list[bool] = []
|
||||
|
||||
class Calculator(App):
|
||||
|
||||
numbers = var("0")
|
||||
show_ac = var(True)
|
||||
value = var("")
|
||||
|
||||
@@ -16,15 +16,17 @@ async def test_installed_screens():
|
||||
SCREENS = {
|
||||
"home": Screen, # Screen type
|
||||
"one": Screen(), # Screen instance
|
||||
"two": lambda: Screen() # Callable[[], Screen]
|
||||
"two": lambda: Screen(), # Callable[[], Screen]
|
||||
}
|
||||
|
||||
app = ScreensApp()
|
||||
async with app.run_test() as pilot:
|
||||
pilot.app.push_screen("home") # Instantiates and pushes the "home" screen
|
||||
pilot.app.push_screen("one") # Pushes the pre-instantiated "one" screen
|
||||
pilot.app.push_screen("one") # Pushes the pre-instantiated "one" screen
|
||||
pilot.app.push_screen("home") # Pushes the single instance of "home" screen
|
||||
pilot.app.push_screen("two") # Calls the callable, pushes returned Screen instance
|
||||
pilot.app.push_screen(
|
||||
"two"
|
||||
) # Calls the callable, pushes returned Screen instance
|
||||
|
||||
assert len(app.screen_stack) == 5
|
||||
assert app.screen_stack[1] is app.screen_stack[3]
|
||||
@@ -40,10 +42,8 @@ async def test_installed_screens():
|
||||
pilot.app.pop_screen()
|
||||
|
||||
|
||||
|
||||
@skip_py310
|
||||
async def test_screens():
|
||||
|
||||
app = App()
|
||||
app._set_active()
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from rich.segment import Segment
|
||||
from rich.style import Style
|
||||
|
||||
from textual._segment_tools import line_crop, line_trim, line_pad
|
||||
from textual._segment_tools import line_crop, line_pad, line_trim
|
||||
|
||||
|
||||
def test_line_crop():
|
||||
|
||||
@@ -2,9 +2,9 @@ import pytest
|
||||
from rich.segment import Segment
|
||||
from rich.style import Style
|
||||
|
||||
from textual._filter import Monochrome
|
||||
from textual._segment_tools import NoCellPositionForIndex
|
||||
from textual.strip import Strip
|
||||
from textual._filter import Monochrome
|
||||
|
||||
|
||||
def test_cell_length() -> None:
|
||||
|
||||
@@ -46,8 +46,8 @@ async def test_table_clear_with_columns() -> None:
|
||||
assert table.data == {}
|
||||
assert table.row_count == 0
|
||||
|
||||
async def test_table_add_row() -> None:
|
||||
|
||||
async def test_table_add_row() -> None:
|
||||
app = TableApp()
|
||||
async with app.run_test():
|
||||
table = app.query_one(DataTable)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from textual.app import App
|
||||
from textual import events
|
||||
from textual.app import App
|
||||
|
||||
|
||||
async def test_run_test() -> None:
|
||||
|
||||
@@ -113,21 +113,25 @@ def test_query_cursor_right_cursor_at_end_returns_false():
|
||||
editor = TextEditorBackend(CONTENT, len(CONTENT))
|
||||
assert not editor.query_cursor_right()
|
||||
|
||||
|
||||
def test_cursor_text_start_cursor_already_at_start():
|
||||
editor = TextEditorBackend(CONTENT)
|
||||
assert not editor.cursor_text_start()
|
||||
assert editor.cursor_index == 0
|
||||
|
||||
|
||||
def test_cursor_text_start_cursor_in_middle():
|
||||
editor = TextEditorBackend(CONTENT, 6)
|
||||
assert editor.cursor_text_start()
|
||||
assert editor.cursor_index == 0
|
||||
|
||||
|
||||
def test_cursor_text_end_cursor_already_at_end():
|
||||
editor = TextEditorBackend(CONTENT, len(CONTENT))
|
||||
assert not editor.cursor_text_end()
|
||||
assert editor.cursor_index == len(CONTENT)
|
||||
|
||||
|
||||
def test_cursor_text_end_cursor_in_middle():
|
||||
editor = TextEditorBackend(CONTENT, len(CONTENT))
|
||||
assert not editor.cursor_text_end()
|
||||
@@ -140,6 +144,7 @@ def test_insert_at_cursor_cursor_at_start():
|
||||
assert editor.content == "ABC" + CONTENT
|
||||
assert editor.cursor_index == len("ABC")
|
||||
|
||||
|
||||
def test_insert_at_cursor_cursor_in_middle():
|
||||
start_cursor_index = 6
|
||||
editor = TextEditorBackend(CONTENT, start_cursor_index)
|
||||
@@ -154,6 +159,7 @@ def test_insert_at_cursor_cursor_at_end():
|
||||
assert editor.content == CONTENT + "ABC"
|
||||
assert editor.cursor_index == len(editor.content)
|
||||
|
||||
|
||||
def test_get_range():
|
||||
editor = TextEditorBackend(CONTENT)
|
||||
assert editor.get_range(0, 5) == "Hello"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from textual.app import App, ComposeResult
|
||||
from textual import events
|
||||
from textual.app import App, ComposeResult
|
||||
from textual.containers import Container
|
||||
from textual.screen import Screen
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ from textual.app import App, ComposeResult
|
||||
from textual.css.errors import StyleValueError
|
||||
from textual.css.query import NoMatches
|
||||
from textual.geometry import Size
|
||||
from textual.widget import Widget, MountError
|
||||
from textual.widget import MountError, Widget
|
||||
from textual.widgets import Label
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import pytest
|
||||
|
||||
from textual.widget import Widget, MountError
|
||||
from textual.widget import MountError, Widget
|
||||
|
||||
|
||||
class Content(Widget):
|
||||
@@ -12,7 +12,6 @@ class Body(Widget):
|
||||
|
||||
|
||||
def test_find_dom_spot():
|
||||
|
||||
# Build up a "fake" DOM for an application.
|
||||
screen = Widget(name="Screen")
|
||||
header = Widget(name="Header", id="header")
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import pytest
|
||||
|
||||
from textual.app import App
|
||||
from textual.widget import Widget, WidgetError, MountError
|
||||
from textual.widgets import Static
|
||||
from textual.css.query import TooManyMatches
|
||||
from textual.widget import MountError, Widget, WidgetError
|
||||
from textual.widgets import Static
|
||||
|
||||
|
||||
class SelfOwn(Widget):
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import asyncio
|
||||
|
||||
from textual.app import App
|
||||
from textual.widget import Widget
|
||||
from textual.widgets import Static, Button
|
||||
from textual.containers import Container
|
||||
from textual.widget import Widget
|
||||
from textual.widgets import Button, Static
|
||||
|
||||
|
||||
async def test_remove_single_widget():
|
||||
|
||||
@@ -5,13 +5,13 @@ import pytest
|
||||
|
||||
from textual._xterm_parser import XTermParser
|
||||
from textual.events import (
|
||||
Paste,
|
||||
Key,
|
||||
MouseDown,
|
||||
MouseUp,
|
||||
MouseMove,
|
||||
MouseScrollDown,
|
||||
MouseScrollUp,
|
||||
MouseUp,
|
||||
Paste,
|
||||
)
|
||||
from textual.messages import TerminalSupportsSynchronizedOutput
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import pytest
|
||||
from typing import cast
|
||||
|
||||
import pytest
|
||||
|
||||
from textual.widgets import Tree
|
||||
from textual.widgets._tree import NodeID
|
||||
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from textual.app import App, ComposeResult
|
||||
from textual.widgets import Tree
|
||||
from textual.message import Message
|
||||
from textual.widgets import Tree
|
||||
|
||||
|
||||
class MyTree(Tree[None]):
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import pytest
|
||||
|
||||
from textual.widgets import Tree
|
||||
from textual.widgets.tree import TreeNode
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
from rich.text import Text
|
||||
|
||||
from textual.widgets import Tree
|
||||
from textual.widgets.tree import TreeNode
|
||||
from rich.text import Text
|
||||
|
||||
|
||||
def test_tree_node_label() -> None:
|
||||
|
||||
Reference in New Issue
Block a user