@@ -30,7 +30,12 @@ async def test_async_api_functions(simple_figure, tmp_path):
30
30
31
31
# Test write_fig and compare with calc_fig output
32
32
write_fig_output = tmp_path / "test_write_fig.png"
33
- await kaleido .write_fig (simple_figure , path = str (write_fig_output ))
33
+ res = await kaleido .write_fig (
34
+ simple_figure ,
35
+ path = str (write_fig_output ),
36
+ cancel_on_error = True ,
37
+ )
38
+ assert res is None
34
39
35
40
with Path (write_fig_output ).open ("rb" ) as f : # noqa: ASYNC230
36
41
write_fig_bytes = f .read ()
@@ -40,14 +45,15 @@ async def test_async_api_functions(simple_figure, tmp_path):
40
45
41
46
# Test write_fig_from_object and compare with calc_fig output
42
47
write_fig_from_object_output = tmp_path / "test_write_fig_from_object.png"
43
- await kaleido .write_fig_from_object (
48
+ res = await kaleido .write_fig_from_object (
44
49
[
45
50
{
46
51
"fig" : simple_figure ,
47
52
"path" : write_fig_from_object_output ,
48
53
},
49
54
],
50
55
)
56
+ assert res == ()
51
57
52
58
with Path (write_fig_from_object_output ).open ("rb" ) as f : # noqa: ASYNC230
53
59
write_fig_from_object_bytes = f .read ()
@@ -61,7 +67,7 @@ async def test_async_api_functions(simple_figure, tmp_path):
61
67
assert write_fig_bytes == write_fig_from_object_bytes == calc_result
62
68
63
69
64
- async def test_sync_api_functions (simple_figure , tmp_path ):
70
+ async def test_sync_api_functions (simple_figure , tmp_path ): # noqa: PLR0915
65
71
"""Test sync wrappers with cross-validation."""
66
72
# Get expected bytes from calc_fig for comparison
67
73
expected_bytes = await kaleido .calc_fig (simple_figure )
@@ -88,22 +94,28 @@ async def test_sync_api_functions(simple_figure, tmp_path):
88
94
assert calc_result_1 == expected_bytes
89
95
90
96
# Test write_fig_sync
91
- kaleido .write_fig_sync (simple_figure , path = str (write_fig_output_1 ))
97
+ res = kaleido .write_fig_sync (
98
+ simple_figure ,
99
+ path = str (write_fig_output_1 ),
100
+ cancel_on_error = True ,
101
+ )
102
+ assert res is None
92
103
93
104
with Path (write_fig_output_1 ).open ("rb" ) as f : # noqa: ASYNC230
94
105
write_fig_bytes_1 = f .read ()
95
106
assert write_fig_bytes_1 == expected_bytes
96
107
assert write_fig_bytes_1 .startswith (b"\x89 PNG\r \n \x1a \n " ), "Not a PNG file"
97
108
98
109
# Test write_fig_from_object_sync
99
- kaleido .write_fig_from_object_sync (
110
+ res = kaleido .write_fig_from_object_sync (
100
111
[
101
112
{
102
113
"fig" : simple_figure ,
103
114
"path" : write_fig_from_object_output_1 ,
104
115
},
105
116
],
106
117
)
118
+ assert res == ()
107
119
108
120
with Path (write_fig_from_object_output_1 ).open ("rb" ) as f : # noqa: ASYNC230
109
121
from_object_bytes_1 = f .read ()
@@ -140,22 +152,25 @@ async def test_sync_api_functions(simple_figure, tmp_path):
140
152
assert calc_result_2 == expected_bytes
141
153
142
154
# Test write_fig_sync
143
- kaleido .write_fig_sync (simple_figure , path = str (write_fig_output_2 ))
155
+ res = kaleido .write_fig_sync (simple_figure , path = str (write_fig_output_2 ))
156
+ assert res == ()
144
157
145
158
with Path (write_fig_output_2 ).open ("rb" ) as f : # noqa: ASYNC230
146
159
write_fig_bytes_2 = f .read ()
147
160
assert write_fig_bytes_2 == expected_bytes
148
161
assert write_fig_bytes_2 .startswith (b"\x89 PNG\r \n \x1a \n " ), "Not a PNG file"
149
162
150
163
# Test write_fig_from_object_sync
151
- kaleido .write_fig_from_object_sync (
164
+ res = kaleido .write_fig_from_object_sync (
152
165
[
153
166
{
154
167
"fig" : simple_figure ,
155
168
"path" : write_fig_from_object_output_2 ,
156
169
},
157
170
],
171
+ cancel_on_error = True ,
158
172
)
173
+ assert res is None
159
174
160
175
with Path (write_fig_from_object_output_2 ).open ("rb" ) as f : # noqa: ASYNC230
161
176
from_object_bytes_2 = f .read ()
0 commit comments