Skip to content

Commit 02ac1ce

Browse files
committed
Check returns in public api tests.
1 parent 6379dce commit 02ac1ce

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

src/py/tests/test_public_api.py

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,12 @@ async def test_async_api_functions(simple_figure, tmp_path):
3030

3131
# Test write_fig and compare with calc_fig output
3232
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
3439

3540
with Path(write_fig_output).open("rb") as f: # noqa: ASYNC230
3641
write_fig_bytes = f.read()
@@ -40,14 +45,15 @@ async def test_async_api_functions(simple_figure, tmp_path):
4045

4146
# Test write_fig_from_object and compare with calc_fig output
4247
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(
4449
[
4550
{
4651
"fig": simple_figure,
4752
"path": write_fig_from_object_output,
4853
},
4954
],
5055
)
56+
assert res == ()
5157

5258
with Path(write_fig_from_object_output).open("rb") as f: # noqa: ASYNC230
5359
write_fig_from_object_bytes = f.read()
@@ -61,7 +67,7 @@ async def test_async_api_functions(simple_figure, tmp_path):
6167
assert write_fig_bytes == write_fig_from_object_bytes == calc_result
6268

6369

64-
async def test_sync_api_functions(simple_figure, tmp_path):
70+
async def test_sync_api_functions(simple_figure, tmp_path): # noqa: PLR0915
6571
"""Test sync wrappers with cross-validation."""
6672
# Get expected bytes from calc_fig for comparison
6773
expected_bytes = await kaleido.calc_fig(simple_figure)
@@ -88,22 +94,28 @@ async def test_sync_api_functions(simple_figure, tmp_path):
8894
assert calc_result_1 == expected_bytes
8995

9096
# 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
92103

93104
with Path(write_fig_output_1).open("rb") as f: # noqa: ASYNC230
94105
write_fig_bytes_1 = f.read()
95106
assert write_fig_bytes_1 == expected_bytes
96107
assert write_fig_bytes_1.startswith(b"\x89PNG\r\n\x1a\n"), "Not a PNG file"
97108

98109
# Test write_fig_from_object_sync
99-
kaleido.write_fig_from_object_sync(
110+
res = kaleido.write_fig_from_object_sync(
100111
[
101112
{
102113
"fig": simple_figure,
103114
"path": write_fig_from_object_output_1,
104115
},
105116
],
106117
)
118+
assert res == ()
107119

108120
with Path(write_fig_from_object_output_1).open("rb") as f: # noqa: ASYNC230
109121
from_object_bytes_1 = f.read()
@@ -140,22 +152,25 @@ async def test_sync_api_functions(simple_figure, tmp_path):
140152
assert calc_result_2 == expected_bytes
141153

142154
# 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 == ()
144157

145158
with Path(write_fig_output_2).open("rb") as f: # noqa: ASYNC230
146159
write_fig_bytes_2 = f.read()
147160
assert write_fig_bytes_2 == expected_bytes
148161
assert write_fig_bytes_2.startswith(b"\x89PNG\r\n\x1a\n"), "Not a PNG file"
149162

150163
# Test write_fig_from_object_sync
151-
kaleido.write_fig_from_object_sync(
164+
res = kaleido.write_fig_from_object_sync(
152165
[
153166
{
154167
"fig": simple_figure,
155168
"path": write_fig_from_object_output_2,
156169
},
157170
],
171+
cancel_on_error=True,
158172
)
173+
assert res is None
159174

160175
with Path(write_fig_from_object_output_2).open("rb") as f: # noqa: ASYNC230
161176
from_object_bytes_2 = f.read()

0 commit comments

Comments
 (0)