File: test_effects.py

package info (click to toggle)
terminaltexteffects 0.14.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,324 kB
  • sloc: python: 16,857; makefile: 3
file content (75 lines) | stat: -rw-r--r-- 2,798 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import pytest

from terminaltexteffects.effects import effect_colorshift, effect_matrix, effect_thunderstorm


@pytest.mark.smoke
@pytest.mark.effects
@pytest.mark.parametrize(
    "input_data",
    ["empty", "single_char", "single_column", "single_row", "medium", "tabs", "color_sequences"],
    indirect=True,
)
def test_effect(effect, input_data, terminal_config_default_no_framerate) -> None:
    effect = effect(input_data)
    # customize some effect configs to shorten testing time
    if isinstance(effect, effect_matrix.Matrix):
        effect.effect_config.rain_time = 1
    elif isinstance(effect, effect_thunderstorm.Thunderstorm):
        effect.effect_config.storm_time = 1
    effect.terminal_config = terminal_config_default_no_framerate

    with effect.terminal_output() as terminal:
        for frame in effect:
            terminal.print(frame)


@pytest.mark.smoke
@pytest.mark.effects
@pytest.mark.parametrize("input_data", ["medium", "color_sequences"], indirect=True)
@pytest.mark.parametrize("existing_color_handling", ["always", "dynamic", "ignore"])
def test_effect_color_sequence_handling(
    effect,
    input_data,
    terminal_config_default_no_framerate,
    existing_color_handling,
) -> None:
    effect = effect(input_data)
    if isinstance(effect, effect_matrix.Matrix):
        effect.effect_config.rain_time = 1
    elif isinstance(effect, effect_thunderstorm.Thunderstorm):
        effect.effect_config.storm_time = 1
    effect.terminal_config = terminal_config_default_no_framerate
    effect.terminal_config.existing_color_handling = existing_color_handling

    with effect.terminal_output() as terminal:
        for frame in effect:
            terminal.print(frame)


@pytest.mark.visual
@pytest.mark.parametrize("input_data", ["large"], indirect=True)
def test_effect_visual(effect, input_data) -> None:
    # customize some effect configs to shorten testing time or test
    # specific features
    effect = effect(input_data)
    if isinstance(effect, effect_matrix.Matrix):
        effect.effect_config.rain_time = 5
    elif isinstance(effect, effect_thunderstorm.Thunderstorm):
        effect.effect_config.storm_time = 1
    elif isinstance(effect, effect_colorshift.ColorShift):
        effect.effect_config.cycles = 2
    with effect.terminal_output() as terminal:
        for frame in effect:
            terminal.print(frame)


@pytest.mark.skip
@pytest.mark.manual
@pytest.mark.parametrize("input_data", ["canvas"], indirect=True)
def test_canvas_anchoring_large_small_canvas(input_data, effect, terminal_config_with_anchoring) -> None:
    effect = effect(input_data)
    effect.terminal_config = terminal_config_with_anchoring
    with effect.terminal_output() as terminal:
        for frame in effect:
            terminal.print(frame)