1
+ import pytest
1
2
import sys
2
3
3
4
if sys .version_info < (3 ,10 ):
4
5
pytest .skip ("Skipping pyodide tests on older Python" , allow_module_level = True )
5
6
6
7
from pytest_pyodide import run_in_pyodide
7
- from .fixtures import package_wheel , input_data
8
+ from pytest_pyodide .decorator import copy_files_to_pyodide
9
+ from .fixtures import input_file_list
8
10
11
+ file_list = input_file_list ()
12
+
13
+ @copy_files_to_pyodide (file_list = file_list ,install_wheels = True )
9
14
@run_in_pyodide (packages = ['micropip' , 'numpy' ])
10
- async def test_compare_double_images_async (selenium , package_wheel , input_data ):
15
+ async def test_compare_double_images_async (selenium ):
11
16
import micropip
12
- await micropip .install (package_wheel )
13
17
await micropip .install ('itkwasm-image-io-emscripten' )
14
- def write_input_data_to_fs (input_data , filename ):
15
- with open (filename , 'wb' ) as fp :
16
- fp .write (input_data [filename ])
18
+
19
+ from itkwasm_compare_images_emscripten import compare_double_images_async
17
20
18
21
import numpy as np
19
22
from itkwasm import Image
@@ -22,11 +25,9 @@ def write_input_data_to_fs(input_data, filename):
22
25
from itkwasm_image_io_emscripten import imread_async
23
26
24
27
test_image_file = 'cake_easy.iwi.cbor'
25
- write_input_data_to_fs (input_data , test_image_file )
26
28
test_image = await imread_async (test_image_file )
27
29
28
30
baseline_image_file = 'cake_hard.iwi.cbor'
29
- write_input_data_to_fs (input_data , baseline_image_file )
30
31
baseline_image = await imread_async (baseline_image_file )
31
32
32
33
metrics , difference_image , difference_image_rendering = await compare_double_images_async (test_image , baseline_images = [baseline_image ])
@@ -41,14 +42,11 @@ def write_input_data_to_fs(input_data, filename):
41
42
assert difference_image .imageType .componentType == 'float64'
42
43
assert difference_image_rendering .imageType .componentType == 'uint8'
43
44
45
+ @copy_files_to_pyodide (file_list = file_list ,install_wheels = True )
44
46
@run_in_pyodide (packages = ['micropip' , 'numpy' ])
45
- async def test_compare_images_async (selenium , package_wheel , input_data ):
47
+ async def test_compare_images_async (selenium ):
46
48
import micropip
47
- await micropip .install (package_wheel )
48
49
await micropip .install ('itkwasm-image-io-emscripten' )
49
- def write_input_data_to_fs (input_data , filename ):
50
- with open (filename , 'wb' ) as fp :
51
- fp .write (input_data [filename ])
52
50
53
51
from itkwasm_compare_images_emscripten import compare_images_async
54
52
from itkwasm_image_io_emscripten import imread_async
@@ -57,11 +55,9 @@ def write_input_data_to_fs(input_data, filename):
57
55
from itkwasm .pyodide import to_js as itkwasm_to_js
58
56
59
57
test_image_file = 'cake_easy.iwi.cbor'
60
- write_input_data_to_fs (input_data , test_image_file )
61
58
test_image = await imread_async (test_image_file )
62
59
63
60
baseline_image_file = 'cake_hard.iwi.cbor'
64
- write_input_data_to_fs (input_data , baseline_image_file )
65
61
baseline_image = await imread_async (baseline_image_file )
66
62
67
63
metrics , difference_image , difference_image_rendering = await compare_images_async (test_image , baseline_images = [baseline_image ])
@@ -77,11 +73,9 @@ def write_input_data_to_fs(input_data, filename):
77
73
assert difference_image_rendering .imageType .componentType == 'uint8'
78
74
79
75
test_image_file = 'cake_easy.png'
80
- write_input_data_to_fs (input_data , test_image_file )
81
76
test_image = await imread_async (test_image_file )
82
77
83
78
baseline_image_file = 'cake_hard.png'
84
- write_input_data_to_fs (input_data , baseline_image_file )
85
79
baseline_image = await imread_async (baseline_image_file )
86
80
87
81
metrics , difference_image , difference_image_rendering = await compare_images_async (test_image , baseline_images = [baseline_image ])
@@ -97,11 +91,9 @@ def write_input_data_to_fs(input_data, filename):
97
91
assert difference_image_rendering .imageType .componentType == 'uint8'
98
92
99
93
test_image_file = 'apple.jpg'
100
- write_input_data_to_fs (input_data , test_image_file )
101
94
test_image = await imread_async (test_image_file )
102
95
103
96
baseline_image_file = 'orange.jpg'
104
- write_input_data_to_fs (input_data , baseline_image_file )
105
97
baseline_image = await imread_async (baseline_image_file )
106
98
107
99
metrics , difference_image , difference_image_rendering = await compare_images_async (test_image , baseline_images = [baseline_image ])
0 commit comments