| Total Complexity | 1 |
| Total Lines | 27 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | import pytest |
||
| 2 | |||
| 3 | |||
| 4 | def test_nst_produces_same_image_when_run_on_different_processes( |
||
| 5 | test_suite, |
||
| 6 | ): |
||
| 7 | from pathlib import Path |
||
| 8 | from numpy.typing import NDArray |
||
| 9 | import imageio |
||
| 10 | # GIVEN the Generated Image from the NST algorithm run on a single process |
||
| 11 | run_1_gen_img_path: Path = Path(test_suite) / 'data' / \ |
||
| 12 | 'canoe_water_w300-h225.jpg+blue-red_w300-h225.jpg-100-demo-gui-run-1.png' |
||
| 13 | |||
| 14 | # GIVEN the Generated Image from the NST algorithm run on another process |
||
| 15 | run_2_gen_img_path: Path = Path(test_suite) / 'data' / \ |
||
| 16 | 'canoe_water_w300-h225.jpg+blue-red_w300-h225.jpg-100-demo-gui-run-2.png' |
||
| 17 | |||
| 18 | # WHEN loading the images into memory |
||
| 19 | array_1: NDArray = imageio.imread(str(run_1_gen_img_path)) |
||
| 20 | array_2: NDArray = imageio.imread(str(run_2_gen_img_path)) |
||
| 21 | |||
| 22 | # WHEN comparing the two images, by comparing their pixel values (arrays) |
||
| 23 | all_array_values_are_equal: bool = (array_1 == array_2).all() |
||
| 24 | |||
| 25 | # THEN the two images should be the same |
||
| 26 | assert all_array_values_are_equal |
||
| 27 |