mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
test fix
This commit is contained in:
@@ -59,7 +59,6 @@ def snap_compare(
|
||||
"""
|
||||
node = request.node
|
||||
app = import_app(app_path)
|
||||
compare.app = app
|
||||
actual_screenshot = take_svg_screenshot(
|
||||
app=app,
|
||||
press=press,
|
||||
@@ -69,7 +68,9 @@ def snap_compare(
|
||||
|
||||
if result is False:
|
||||
# The split and join below is a mad hack, sorry...
|
||||
node.stash[TEXTUAL_SNAPSHOT_SVG_KEY] = "\n".join(str(snapshot).splitlines()[1:-1])
|
||||
node.stash[TEXTUAL_SNAPSHOT_SVG_KEY] = "\n".join(
|
||||
str(snapshot).splitlines()[1:-1]
|
||||
)
|
||||
node.stash[TEXTUAL_ACTUAL_SVG_KEY] = actual_screenshot
|
||||
node.stash[TEXTUAL_APP_KEY] = app
|
||||
else:
|
||||
@@ -85,6 +86,7 @@ class SvgSnapshotDiff:
|
||||
"""Model representing a diff between current screenshot of an app,
|
||||
and the snapshot on disk. This is ultimately intended to be used in
|
||||
a Jinja2 template."""
|
||||
|
||||
snapshot: Optional[str]
|
||||
actual: Optional[str]
|
||||
test_name: str
|
||||
@@ -119,7 +121,7 @@ def pytest_sessionfinish(
|
||||
snapshot=str(snapshot_svg),
|
||||
actual=str(actual_svg),
|
||||
file_similarity=100
|
||||
* difflib.SequenceMatcher(
|
||||
* difflib.SequenceMatcher(
|
||||
a=str(snapshot_svg), b=str(actual_svg)
|
||||
).ratio(),
|
||||
test_name=name,
|
||||
@@ -176,7 +178,9 @@ def pytest_terminal_summary(
|
||||
if diffs:
|
||||
snapshot_report_location = config._textual_snapshot_html_report
|
||||
console.rule("[b red]Textual Snapshot Report", style="red")
|
||||
console.print(f"\n[black on red]{len(diffs)} mismatched snapshots[/]\n"
|
||||
f"\n[b]View the [link=file://{snapshot_report_location}]failure report[/].\n")
|
||||
console.print(
|
||||
f"\n[black on red]{len(diffs)} mismatched snapshots[/]\n"
|
||||
f"\n[b]View the [link=file://{snapshot_report_location}]failure report[/].\n"
|
||||
)
|
||||
console.print(f"[dim]{snapshot_report_location}\n")
|
||||
console.rule(style="red")
|
||||
|
||||
@@ -66,22 +66,11 @@ def test_input_and_focus(snap_compare):
|
||||
]
|
||||
assert snap_compare("docs/examples/widgets/input.py", press=press)
|
||||
|
||||
# Assert that the state of the Input is what we'd expect
|
||||
# app: App = snap_compare.app
|
||||
# input: Input = app.query_one(Input)
|
||||
# assert input.value == "Darren"
|
||||
# assert input.cursor_position == 6
|
||||
# assert input.view_position == 0
|
||||
|
||||
|
||||
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"])
|
||||
|
||||
# app = snap_compare.app
|
||||
# button: Button = app.query_one(Button)
|
||||
# assert app.focused is button
|
||||
|
||||
|
||||
def test_datatable_render(snap_compare):
|
||||
press = ["tab", "down", "down", "right", "up", "left"]
|
||||
|
||||
Reference in New Issue
Block a user