mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
Testing to ensure layout can properly be set via view
This commit is contained in:
@@ -30,9 +30,9 @@ from .transition import Transition
|
||||
from ..geometry import Spacing, SpacingDimensions
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..layout import Layout
|
||||
from .styles import Styles
|
||||
from .styles import DockGroup
|
||||
from ..layout import Layout
|
||||
from ..layouts.factory import LayoutName
|
||||
|
||||
|
||||
@@ -313,7 +313,7 @@ class LayoutProperty:
|
||||
layout (LayoutName | Layout): The layout to use. You can supply a ``LayoutName``
|
||||
(a string literal such as ``"dock"``) or a ``Layout`` object.
|
||||
"""
|
||||
from ..layouts.factory import get_layout # Prevents circular import
|
||||
from ..layouts.factory import get_layout, Layout # Prevents circular import
|
||||
|
||||
obj.refresh(True)
|
||||
if isinstance(layout, Layout):
|
||||
|
||||
18
tests/test_view.py
Normal file
18
tests/test_view.py
Normal file
@@ -0,0 +1,18 @@
|
||||
import pytest
|
||||
|
||||
from textual.layouts.dock import DockLayout
|
||||
from textual.layouts.grid import GridLayout
|
||||
from textual.layouts.vertical import VerticalLayout
|
||||
from textual.view import View
|
||||
|
||||
|
||||
@pytest.mark.parametrize("layout_name, layout_type", [
|
||||
["dock", DockLayout],
|
||||
["grid", GridLayout],
|
||||
["vertical", VerticalLayout],
|
||||
])
|
||||
def test_view_layout_get_and_set(layout_name, layout_type):
|
||||
view = View()
|
||||
view.layout = layout_name
|
||||
assert type(view.layout) is layout_type
|
||||
assert view.styles.layout is view.layout
|
||||
Reference in New Issue
Block a user