mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
Updates
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -5,10 +5,10 @@ from functools import partial
|
|||||||
from operator import attrgetter
|
from operator import attrgetter
|
||||||
from os import PathLike
|
from os import PathLike
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Union, List, Optional, Any, Callable
|
from typing import Union, List, Optional, Callable
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from _pytest.fixtures import FixtureDef, SubRequest, FixtureRequest
|
from _pytest.fixtures import FixtureRequest
|
||||||
from jinja2 import Template
|
from jinja2 import Template
|
||||||
from rich.console import Console
|
from rich.console import Console
|
||||||
from rich.panel import Panel
|
from rich.panel import Panel
|
||||||
@@ -49,20 +49,6 @@ class SvgSnapshotDiff:
|
|||||||
line_number: int
|
line_number: int
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
# def pytest_runtestloop(session: "Session") -> Optional[object]:
|
|
||||||
|
|
||||||
@pytest.hookimpl(hookwrapper=True)
|
|
||||||
def pytest_pyfunc_call(pyfuncitem: "pytest.Function") -> Optional[object]:
|
|
||||||
"""Call underlying test function.
|
|
||||||
|
|
||||||
Stops at first non-None result, see :ref:`firstresult`.
|
|
||||||
"""
|
|
||||||
# Before
|
|
||||||
yield
|
|
||||||
# After
|
|
||||||
|
|
||||||
|
|
||||||
def pytest_runtest_teardown(item: pytest.Item, nextitem: Optional[pytest.Item]) -> None:
|
def pytest_runtest_teardown(item: pytest.Item, nextitem: Optional[pytest.Item]) -> None:
|
||||||
"""Called to perform the teardown phase for a test item.
|
"""Called to perform the teardown phase for a test item.
|
||||||
|
|
||||||
@@ -79,26 +65,6 @@ def pytest_runtest_teardown(item: pytest.Item, nextitem: Optional[pytest.Item])
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
@pytest.hookimpl(hookwrapper=True)
|
|
||||||
def pytest_fixture_setup(
|
|
||||||
fixturedef: FixtureDef[Any], request: SubRequest
|
|
||||||
) -> Optional[object]:
|
|
||||||
"""Perform fixture setup execution.
|
|
||||||
|
|
||||||
:returns: The return value of the call to the fixture function.
|
|
||||||
|
|
||||||
Stops at first non-None result, see :ref:`firstresult`.
|
|
||||||
|
|
||||||
.. note::
|
|
||||||
If the fixture function returns None, other implementations of
|
|
||||||
this hook function will continue to be called, according to the
|
|
||||||
behavior of the :ref:`firstresult` option.
|
|
||||||
"""
|
|
||||||
value = yield
|
|
||||||
value = value.get_result()
|
|
||||||
value = repr(value)
|
|
||||||
|
|
||||||
|
|
||||||
def pytest_sessionfinish(
|
def pytest_sessionfinish(
|
||||||
session: "pytest.Session",
|
session: "pytest.Session",
|
||||||
exitstatus: Union[int, "pytest.ExitCode"],
|
exitstatus: Union[int, "pytest.ExitCode"],
|
||||||
@@ -120,7 +86,9 @@ def pytest_sessionfinish(
|
|||||||
SvgSnapshotDiff(
|
SvgSnapshotDiff(
|
||||||
snapshot=str(snapshot_svg),
|
snapshot=str(snapshot_svg),
|
||||||
actual=str(actual_svg),
|
actual=str(actual_svg),
|
||||||
file_similarity=100 * difflib.SequenceMatcher(a=str(snapshot_svg), b=str(actual_svg)).ratio(),
|
file_similarity=100 * difflib.SequenceMatcher(a=str(snapshot_svg),
|
||||||
|
b=str(
|
||||||
|
actual_svg)).ratio(),
|
||||||
test_name=name,
|
test_name=name,
|
||||||
path=path,
|
path=path,
|
||||||
line_number=line_index + 1,
|
line_number=line_index + 1,
|
||||||
@@ -143,8 +111,8 @@ def pytest_sessionfinish(
|
|||||||
diffs=diffs,
|
diffs=diffs,
|
||||||
passes=num_snapshots_passing,
|
passes=num_snapshots_passing,
|
||||||
fails=num_fails,
|
fails=num_fails,
|
||||||
pass_percentage=100*(num_snapshots_passing/num_snapshot_tests),
|
pass_percentage=100 * (num_snapshots_passing / (num_snapshot_tests + 1)),
|
||||||
fail_percentage=100*(num_fails/num_snapshot_tests),
|
fail_percentage=100 * (num_fails / (num_snapshot_tests + 1)),
|
||||||
num_snapshot_tests=num_snapshot_tests,
|
num_snapshot_tests=num_snapshot_tests,
|
||||||
now=datetime.utcnow()
|
now=datetime.utcnow()
|
||||||
)
|
)
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -49,7 +49,7 @@
|
|||||||
<strong class="font-monospace">
|
<strong class="font-monospace">
|
||||||
{{ diff.test_name }}
|
{{ diff.test_name }}
|
||||||
</strong>
|
</strong>
|
||||||
<span class="text-muted">({{ "%.2f"|format(diff.file_similarity) }}% similar)</span>
|
<span class="text-muted">({{ "%.2f"|format(diff.file_similarity) }}% source similarity)</span>
|
||||||
</div>
|
</div>
|
||||||
<span class="text-muted">{{ diff.path }}:{{ diff.line_number }}</span>
|
<span class="text-muted">{{ diff.path }}:{{ diff.line_number }}</span>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -6,9 +6,25 @@ def test_grid_layout_basic_overflow(snap_compare):
|
|||||||
assert snap_compare("docs/examples/guide/layout/grid_layout2.py")
|
assert snap_compare("docs/examples/guide/layout/grid_layout2.py")
|
||||||
|
|
||||||
|
|
||||||
def test_combining_layouts(snap_compare):
|
def test_grid_layout_gutter(snap_compare):
|
||||||
assert snap_compare("docs/examples/guide/layout/combining_layouts.py")
|
assert snap_compare("docs/examples/guide/layout/grid_layout7_gutter.py")
|
||||||
|
|
||||||
|
|
||||||
def test_layers(snap_compare):
|
def test_layers(snap_compare):
|
||||||
assert snap_compare("docs/examples/guide/layout/layers.py")
|
assert snap_compare("docs/examples/guide/layout/layers.py")
|
||||||
|
|
||||||
|
|
||||||
|
def test_center_layout(snap_compare):
|
||||||
|
assert snap_compare("docs/examples/guide/layout/center_layout.py")
|
||||||
|
|
||||||
|
|
||||||
|
def test_horizontal_layout(snap_compare):
|
||||||
|
assert snap_compare("docs/examples/guide/layout/horizontal_layout.py")
|
||||||
|
|
||||||
|
|
||||||
|
def test_vertical_layout(snap_compare):
|
||||||
|
assert snap_compare("docs/examples/guide/layout/vertical_layout.py")
|
||||||
|
|
||||||
|
|
||||||
|
def test_dock_layout_sidebar(snap_compare):
|
||||||
|
assert snap_compare("docs/examples/guide/layout/dock_layout2_sidebar.py")
|
||||||
|
|||||||
Reference in New Issue
Block a user