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 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
|
from __future__ import annotations
import gc
import platform
from typing import TYPE_CHECKING
import pytest
from . import util_test
if TYPE_CHECKING:
from .util_config import Config
def cleanup(config: Config) -> None:
if platform.python_implementation() == "PyPy":
config.clear()
gc.collect()
@pytest.mark.image
@pytest.mark.text
@pytest.mark.parametrize("show_text", [False, True])
@pytest.mark.parametrize("name", util_test.all_names())
def test_config_filled(show_text: bool, name: str) -> None:
from . import util_config
from .image_comparison import compare_images
config = util_config.ConfigFilled(name, show_text=show_text)
image_buffer = config.save_to_buffer()
suffix = "" if show_text else "_no_text"
compare_images(image_buffer, f"config_filled{suffix}.png", name)
cleanup(config)
@pytest.mark.image
@pytest.mark.text
@pytest.mark.parametrize("show_text", [False, True])
@pytest.mark.parametrize("name", util_test.quad_as_tri_names())
def test_config_filled_quad_as_tri(show_text: bool, name: str) -> None:
from . import util_config
from .image_comparison import compare_images
config = util_config.ConfigFilled(name, quad_as_tri=True, show_text=show_text)
image_buffer = config.save_to_buffer()
suffix = "" if show_text else "_no_text"
compare_images(image_buffer, f"config_filled_quad_as_tri{suffix}.png", name)
cleanup(config)
@pytest.mark.image
@pytest.mark.text
@pytest.mark.parametrize("show_text", [False, True])
@pytest.mark.parametrize("name", util_test.corner_mask_names())
def test_config_filled_corner(show_text: bool, name: str) -> None:
from . import util_config
from .image_comparison import compare_images
config = util_config.ConfigFilledCorner(name, show_text=show_text)
image_buffer = config.save_to_buffer()
suffix = "" if show_text else "_no_text"
compare_images(image_buffer, f"config_filled_corner{suffix}.png", name)
cleanup(config)
@pytest.mark.image
@pytest.mark.text
@pytest.mark.parametrize("show_text", [False, True])
@pytest.mark.parametrize("name", util_test.all_names())
def test_config_lines(show_text: bool, name: str) -> None:
from . import util_config
from .image_comparison import compare_images
if name == "mpl2005":
pytest.skip() # Line directions are not consistent.
config = util_config.ConfigLines(name, show_text=show_text)
image_buffer = config.save_to_buffer()
suffix = "" if show_text else "_no_text"
compare_images(image_buffer, f"config_lines{suffix}.png", name)
cleanup(config)
@pytest.mark.image
@pytest.mark.text
@pytest.mark.parametrize("show_text", [False, True])
@pytest.mark.parametrize("name", util_test.quad_as_tri_names())
def test_config_lines_quad_as_tri(show_text: bool, name: str) -> None:
from . import util_config
from .image_comparison import compare_images
config = util_config.ConfigLines(name, quad_as_tri=True, show_text=show_text)
image_buffer = config.save_to_buffer()
suffix = "" if show_text else "_no_text"
compare_images(image_buffer, f"config_lines_quad_as_tri{suffix}.png", name)
cleanup(config)
@pytest.mark.image
@pytest.mark.text
@pytest.mark.parametrize("show_text", [False, True])
@pytest.mark.parametrize("name", util_test.corner_mask_names())
def test_config_lines_corner(show_text: bool, name: str) -> None:
from . import util_config
from .image_comparison import compare_images
config = util_config.ConfigLinesCorner(name, show_text=show_text)
image_buffer = config.save_to_buffer()
suffix = "" if show_text else "_no_text"
compare_images(image_buffer, f"config_lines_corner{suffix}.png", name)
cleanup(config)
|