Passed
Push — master ( c3d045...3525ae )
by Konstantinos
01:55 queued 43s
created

test_nst_results_of_different_processes   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 15
dl 0
loc 27
rs 10
c 0
b 0
f 0
wmc 1

1 Function

Rating   Name   Duplication   Size   Complexity  
A test_nst_produces_same_image_when_run_on_different_processes() 0 23 1
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