diff --git a/src/textual/app.py b/src/textual/app.py index 3142973e6..63c6cfa7c 100644 --- a/src/textual/app.py +++ b/src/textual/app.py @@ -494,18 +494,6 @@ class App(Generic[ReturnType], DOMNode): return DOMQuery(self.screen, selector) - def query_one(self, selector: str) -> DOMNode | None: - """Retrieves a single node via a DOM query in the current screen. - - Args: - selector (str): A CSS selector . - - Returns: - DOMNode | None: The first node matching the query, or None if no node matches the selector. - """ - result = self.query(selector) - return result.first() if len(result) else None - def get_child(self, id: str) -> DOMNode: """Shorthand for self.screen.get_child(id: str) Returns the first child (immediate descendent) of this DOMNode @@ -516,6 +504,9 @@ class App(Generic[ReturnType], DOMNode): Returns: DOMNode: The first child of this node with the specified ID. + + Raises: + NoMatchingNodesError: if no children could be found for this ID """ return self.screen.get_child(id) diff --git a/src/textual/dom.py b/src/textual/dom.py index 86e0c3eb1..23b51dbaa 100644 --- a/src/textual/dom.py +++ b/src/textual/dom.py @@ -397,6 +397,9 @@ class DOMNode(MessagePump): Returns: DOMNode: The first child of this node with the ID. + + Raises: + NoMatchingNodesError: if no children could be found for this ID """ for child in self.children: if child.id == id: diff --git a/src/textual/widget.py b/src/textual/widget.py index d46485df6..e46d9bb76 100644 --- a/src/textual/widget.py +++ b/src/textual/widget.py @@ -403,7 +403,6 @@ class Widget(DOMNode): Returns: Region: The widget region minus scrollbars. """ - # return region show_vertical_scrollbar, show_horizontal_scrollbar = self.scrollbars_enabled if show_horizontal_scrollbar and show_vertical_scrollbar: (region, _, _, _) = region.split(-1, -1) diff --git a/tests/test_integration_layout.py b/tests/test_integration_layout.py index 16105f963..141bb0f38 100644 --- a/tests/test_integration_layout.py +++ b/tests/test_integration_layout.py @@ -1,6 +1,5 @@ from __future__ import annotations import asyncio -import platform from typing import cast, List import pytest @@ -11,9 +10,6 @@ from textual.geometry import Size from textual.widget import Widget from textual.widgets import Placeholder -PLATFORM = platform.system() -WINDOWS = PLATFORM == "Windows" - # Let's allow ourselves some abbreviated names for those tests, # in order to make the test cases a bit easier to read :-) SCREEN_W = 100 # width of our Screens @@ -153,22 +149,11 @@ async def test_composition_of_vertical_container_with_children( expected_screen_size = Size(*screen_size) - # On Windows the screen size is always 1 cell smaller than the requested dimensions. - # Let's take this into account into our "expected_*" measurements: - if WINDOWS: - expected_screen_size = expected_screen_size._replace( - width=expected_screen_size.width - 1 - ) - expected_placeholders_size = ( - expected_placeholders_size[0] - 1, - expected_placeholders_size[1], - ) - async with app.in_running_state(): app.log_tree() # root widget checks: - root_widget = cast(Widget, app.query_one("#root")) + root_widget = cast(Widget, app.get_child("root")) assert root_widget.size == expected_screen_size root_widget_region = app.screen.get_widget_region(root_widget) assert root_widget_region == ( diff --git a/tests/utilities/test_app.py b/tests/utilities/test_app.py index a17c435fc..9bfb8d5d6 100644 --- a/tests/utilities/test_app.py +++ b/tests/utilities/test_app.py @@ -111,6 +111,7 @@ class ConsoleTest(Console): width=width, height=height, force_terminal=True, + legacy_windows=False, )