Fix snapshot test by resetting colour cycle.

This commit is contained in:
Rodrigo Girão Serrão
2022-11-18 15:54:32 +00:00
parent be283ab348
commit 0b30c3a1d5
2 changed files with 8 additions and 0 deletions

View File

@@ -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",

View File

@@ -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")