mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
Snapshotting canonical style property examples
This commit is contained in:
@@ -14,5 +14,3 @@ class GridApp(App):
|
||||
|
||||
|
||||
app = GridApp(css_path="grid.css")
|
||||
if __name__ == "__main__":
|
||||
app.run()
|
||||
|
||||
@@ -13,6 +13,3 @@ class LinksApp(App):
|
||||
|
||||
|
||||
app = LinksApp(css_path="links.css")
|
||||
|
||||
if __name__ == "__main__":
|
||||
app.run()
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1,3 +1,10 @@
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
# --- Layout related stuff ---
|
||||
|
||||
def test_grid_layout_basic(snap_compare):
|
||||
assert snap_compare("docs/examples/guide/layout/grid_layout1.py")
|
||||
|
||||
@@ -26,7 +33,34 @@ def test_dock_layout_sidebar(snap_compare):
|
||||
assert snap_compare("docs/examples/guide/layout/dock_layout2_sidebar.py")
|
||||
|
||||
|
||||
# --- Interacting with widgets ---
|
||||
|
||||
def test_checkboxes(snap_compare):
|
||||
"""Tests checkboxes but also acts a regression test for using
|
||||
width: auto in a Horizontal layout context."""
|
||||
assert snap_compare("docs/examples/widgets/checkbox.py")
|
||||
|
||||
|
||||
def test_input_and_focus(snap_compare):
|
||||
first_field = ["tab"] + list("Darren") # Focus first input, write "Darren"
|
||||
second_field = ["tab"] + list("Burns") # Tab focus to second input, write "Burns"
|
||||
assert snap_compare("docs/examples/widgets/input.py", press=first_field + second_field)
|
||||
|
||||
|
||||
def test_buttons_render(snap_compare):
|
||||
# Testing button rendering. We press tab to focus the first button too.
|
||||
assert snap_compare("docs/examples/widgets/button.py", press=["tab"])
|
||||
|
||||
|
||||
# --- CSS properties ---
|
||||
# We have a canonical example for each CSS property that is shown in their docs.
|
||||
# If any of these change, something has likely broken, so snapshot each of them.
|
||||
|
||||
PATHS = [
|
||||
str(path) for path in Path("docs/examples/styles").iterdir() if path.suffix == ".py"
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.parametrize("path", PATHS)
|
||||
def test_css_property_snapshot(path, snap_compare):
|
||||
assert snap_compare(path)
|
||||
|
||||
Reference in New Issue
Block a user