|
1 | 1 | import shutil |
| 2 | +from pathlib import Path |
2 | 3 |
|
3 | 4 | import pytest |
4 | 5 |
|
@@ -101,12 +102,34 @@ def test_scene_slice(): |
101 | 102 |
|
102 | 103 |
|
103 | 104 | @pytest.mark.parametrize( |
104 | | - "name, scale", [("test", 2), (None, None), (None, 1), ("test2", None)] |
| 105 | + "name, scale, expected_suffix", |
| 106 | + [ |
| 107 | + ("test", 2, ".png"), |
| 108 | + (None, None, ".png"), |
| 109 | + (None, 1, ".png"), |
| 110 | + ("test2", None, ".png"), |
| 111 | + ("test.jpg", 1, ".jpg"), |
| 112 | + ("test.eps", 1, ".eps"), |
| 113 | + ("test.svg", 1, ".svg"), |
| 114 | + ("test.pdf", 1, ".pdf"), |
| 115 | + ("test.tiff", 1, ".png"), |
| 116 | + ], |
105 | 117 | ) |
106 | | -def test_scene_screenshot(name, scale): |
107 | | - s = Scene(screenshots_folder="tests/screenshots") |
108 | | - s.screenshot(name=name, scale=scale) |
109 | | - shutil.rmtree("tests/screenshots") |
| 118 | +def test_scene_screenshot(name, scale, expected_suffix): |
| 119 | + screenshot_folder = Path.home() / "test_screenshots" |
| 120 | + s = Scene(screenshots_folder=screenshot_folder) |
| 121 | + out_path = s.screenshot(name=name, scale=scale) |
| 122 | + |
| 123 | + assert Path(out_path).suffix == expected_suffix |
| 124 | + |
| 125 | + # Vedo exports eps and svg files as gzipped files |
| 126 | + # Append the .gz suffix to the expected path to check if file exists |
| 127 | + if expected_suffix in [".eps", ".svg"]: |
| 128 | + out_path += ".gz" |
| 129 | + |
| 130 | + assert Path(out_path).exists() |
| 131 | + |
| 132 | + shutil.rmtree(screenshot_folder) |
110 | 133 | del s |
111 | 134 |
|
112 | 135 |
|
|
0 commit comments