From 0b30c3a1d5af133f095f42cc92f12b702deffe21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodrigo=20Gir=C3=A3o=20Serr=C3=A3o?= <5621605+RodrigoGiraoSerrao@users.noreply.github.com> Date: Fri, 18 Nov 2022 15:54:32 +0000 Subject: [PATCH] Fix snapshot test by resetting colour cycle. --- src/textual/widgets/_placeholder.py | 5 +++++ tests/snapshot_tests/test_snapshots.py | 3 +++ 2 files changed, 8 insertions(+) diff --git a/src/textual/widgets/_placeholder.py b/src/textual/widgets/_placeholder.py index 835f257e2..a15b9f0ab 100644 --- a/src/textual/widgets/_placeholder.py +++ b/src/textual/widgets/_placeholder.py @@ -74,6 +74,11 @@ class Placeholder(Static): variant: Reactive[PlaceholderVariant] = reactive("default") + @classmethod + def reset_color_cycle(cls) -> None: + """Reset the placeholder background color cycle.""" + cls.COLORS = cycle(_PLACEHOLDER_BACKGROUND_COLORS) + def __init__( self, variant: PlaceholderVariant = "default", diff --git a/tests/snapshot_tests/test_snapshots.py b/tests/snapshot_tests/test_snapshots.py index 4409d03b7..d80b1e700 100644 --- a/tests/snapshot_tests/test_snapshots.py +++ b/tests/snapshot_tests/test_snapshots.py @@ -2,6 +2,8 @@ from pathlib import Path import pytest +from textual.widgets import Placeholder + # These paths should be relative to THIS directory. WIDGET_EXAMPLES_DIR = Path("../../docs/examples/widgets") LAYOUT_EXAMPLES_DIR = Path("../../docs/examples/guide/layout") @@ -79,6 +81,7 @@ def test_buttons_render(snap_compare): def test_placeholder_render(snap_compare): # Testing the rendering of the multiple placeholder variants and labels. + Placeholder.reset_color_cycle() assert snap_compare(WIDGET_EXAMPLES_DIR / "placeholder.py")