Skip to content

Commit 372dbcb

Browse files
committed
add typing and a docstring
1 parent ab4c2d2 commit 372dbcb

File tree

1 file changed

+41
-5
lines changed

1 file changed

+41
-5
lines changed

tests/test_make.py

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,23 +38,59 @@ def dataclass_param(request):
3838
return request.param
3939

4040

41-
def _assert_load(schema, loaded, dumped):
41+
def _assert_load(
42+
schema: t.Type[marshmallow.Schema],
43+
loaded: t.Any,
44+
dumped: t.Dict[t.Any, t.Any],
45+
) -> None:
4246
assert schema.load(dumped) == loaded
4347

4448

45-
def _assert_dump(schema, loaded, dumped):
49+
def _assert_dump(
50+
schema: t.Type[marshmallow.Schema],
51+
loaded: t.Any,
52+
dumped: t.Dict[t.Any, t.Any],
53+
) -> None:
4654
assert schema.dump(loaded) == dumped
4755

4856

49-
def _assert_dump_load(schema, loaded, dumped):
57+
def _assert_dump_load(
58+
schema: t.Type[marshmallow.Schema],
59+
loaded: t.Any,
60+
dumped: t.Dict[t.Any, t.Any],
61+
) -> None:
5062
assert schema.loads(schema.dumps(loaded)) == loaded
5163

5264

53-
def _assert_load_dump(schema, loaded, dumped):
65+
def _assert_load_dump(
66+
schema: t.Type[marshmallow.Schema],
67+
loaded: t.Any,
68+
dumped: t.Dict[t.Any, t.Any],
69+
) -> None:
5470
assert schema.dump(schema.load(dumped)) == dumped
5571

5672

57-
def fixture_from_dict(name, id_to_value):
73+
def fixture_from_dict(
74+
name: str,
75+
id_to_value: t.Mapping[
76+
str,
77+
t.Callable[
78+
[
79+
t.Type[marshmallow.Schema],
80+
t.Dict[t.Any, t.Any],
81+
t.Any,
82+
],
83+
None,
84+
],
85+
],
86+
):
87+
"""
88+
Create fixture parametrized to yield each value and labeled with the
89+
corresponding ID.
90+
:param name: Name of the fixture itself
91+
:param id_to_value: Mapping from ID labels to values
92+
:return: The PyTest fixture
93+
"""
5894
@pytest.fixture(
5995
name=name,
6096
params=id_to_value.values(),

0 commit comments

Comments
 (0)