Skip to content

Commit a788a7f

Browse files
committed
add tests for consistent docstrings
1 parent b840c5c commit a788a7f

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

tests/test_api/test_synchronous.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
from __future__ import annotations
2+
3+
from typing import Final
4+
5+
import pytest
6+
from numpydoc.docscrape import NumpyDocString
7+
8+
from zarr.api import asynchronous, synchronous
9+
10+
MATCHED_EXPORT_NAMES: Final[tuple[str, ...]] = tuple(
11+
sorted(set(synchronous.__all__) | set(asynchronous.__all__))
12+
)
13+
MATCHED_CALLABLE_NAMES: Final[tuple[str, ...]] = tuple(
14+
x for x in MATCHED_EXPORT_NAMES if callable(getattr(synchronous, x))
15+
)
16+
17+
18+
@pytest.mark.parametrize("callable_name", MATCHED_CALLABLE_NAMES)
19+
def test_create_docstrings(callable_name: str) -> None:
20+
"""
21+
Tests that the docstrings for the sync and async define identical parameters.
22+
"""
23+
callable_a = getattr(synchronous, callable_name)
24+
callable_b = getattr(asynchronous, callable_name)
25+
if callable_a.__doc__ is None:
26+
assert callable_b.__doc__ is None
27+
else:
28+
params_a = NumpyDocString(callable_a.__doc__)["Parameters"]
29+
params_b = NumpyDocString(callable_b.__doc__)["Parameters"]
30+
assert params_a == params_b

0 commit comments

Comments
 (0)