From 08864a48dd8feb909080e7a9fa41eb958243514f Mon Sep 17 00:00:00 2001 From: Igor Tatarnikov Date: Wed, 24 Apr 2024 18:49:50 +0100 Subject: [PATCH] Added tests for screenshot suffixes --- tests/test_scene.py | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/tests/test_scene.py b/tests/test_scene.py index a0416f34..c8af38dd 100644 --- a/tests/test_scene.py +++ b/tests/test_scene.py @@ -1,4 +1,5 @@ import shutil +from pathlib import Path import pytest @@ -101,12 +102,24 @@ def test_scene_slice(): @pytest.mark.parametrize( - "name, scale", [("test", 2), (None, None), (None, 1), ("test2", None)] + "name, scale, expected_suffix", [ + ("test", 2, ".png"), + (None, None, ".png"), + (None, 1, ".png"), + ("test2", None, ".png"), + ("test.jpg", 1, ".jpg"), + ("test.eps", 1, ".eps"), + ("test.svg", 1, ".svg"), + ("test.pdf", 1, ".pdf"), + ("test.tiff", 1, ".png"), + ] ) -def test_scene_screenshot(name, scale): - s = Scene(screenshots_folder="tests/screenshots") - s.screenshot(name=name, scale=scale) - shutil.rmtree("tests/screenshots") +def test_scene_screenshot(name, scale, expected_suffix): + screenshot_folder = Path.home() / "test_screenshots" + s = Scene(screenshots_folder=screenshot_folder) + out_path = s.screenshot(name=name, scale=scale) + assert Path(out_path).suffix == expected_suffix + shutil.rmtree(screenshot_folder) del s