4040unstructure_strats = one_of (just (s ) for s in UnstructureStrategy )
4141
4242
43- @given (simple_typed_classes () | simple_typed_dataclasses (), booleans ())
43+ @given (
44+ simple_typed_classes (allow_nan = False ) | simple_typed_dataclasses (allow_nan = False ),
45+ booleans (),
46+ )
4447def test_simple_roundtrip (cls_and_vals , detailed_validation ):
4548 """
4649 Simple classes with metadata can be unstructured and restructured.
@@ -54,8 +57,8 @@ def test_simple_roundtrip(cls_and_vals, detailed_validation):
5457
5558
5659@given (
57- simple_typed_classes (kw_only = False , newtypes = False )
58- | simple_typed_dataclasses (newtypes = False ),
60+ simple_typed_classes (kw_only = False , newtypes = False , allow_nan = False )
61+ | simple_typed_dataclasses (newtypes = False , allow_nan = False ),
5962 booleans (),
6063)
6164def test_simple_roundtrip_tuple (cls_and_vals , dv : bool ):
@@ -72,7 +75,7 @@ def test_simple_roundtrip_tuple(cls_and_vals, dv: bool):
7275 assert inst == converter .structure (unstructured , cl )
7376
7477
75- @given (simple_typed_attrs (defaults = True ))
78+ @given (simple_typed_attrs (defaults = True , allow_nan = False ))
7679def test_simple_roundtrip_defaults (attr_and_vals ):
7780 """
7881 Simple classes with metadata can be unstructured and restructured.
@@ -87,7 +90,9 @@ def test_simple_roundtrip_defaults(attr_and_vals):
8790 assert inst == converter .structure (converter .unstructure (inst ), cl )
8891
8992
90- @given (simple_typed_attrs (defaults = True , kw_only = False , newtypes = False ))
93+ @given (
94+ simple_typed_attrs (defaults = True , kw_only = False , newtypes = False , allow_nan = False )
95+ )
9196def test_simple_roundtrip_defaults_tuple (attr_and_vals ):
9297 """
9398 Simple classes with metadata can be unstructured and restructured.
@@ -103,7 +108,8 @@ def test_simple_roundtrip_defaults_tuple(attr_and_vals):
103108
104109
105110@given (
106- simple_typed_classes (newtypes = False ) | simple_typed_dataclasses (newtypes = False ),
111+ simple_typed_classes (newtypes = False , allow_nan = False )
112+ | simple_typed_dataclasses (newtypes = False , allow_nan = False ),
107113 unstructure_strats ,
108114)
109115def test_simple_roundtrip_with_extra_keys_forbidden (cls_and_vals , strat ):
@@ -200,7 +206,7 @@ class A:
200206 assert cve .value .exceptions [0 ].extra_fields == {"b" }
201207
202208
203- @given (nested_typed_classes (defaults = True , min_attrs = 1 ), booleans ())
209+ @given (nested_typed_classes (defaults = True , min_attrs = 1 , allow_nan = False ), booleans ())
204210def test_nested_roundtrip (cls_and_vals , omit_if_default ):
205211 """
206212 Nested classes with metadata can be unstructured and restructured.
@@ -214,7 +220,9 @@ def test_nested_roundtrip(cls_and_vals, omit_if_default):
214220
215221
216222@given (
217- nested_typed_classes (defaults = True , min_attrs = 1 , kw_only = False , newtypes = False ),
223+ nested_typed_classes (
224+ defaults = True , min_attrs = 1 , kw_only = False , newtypes = False , allow_nan = False
225+ ),
218226 booleans (),
219227)
220228def test_nested_roundtrip_tuple (cls_and_vals , omit_if_default : bool ):
@@ -233,8 +241,8 @@ def test_nested_roundtrip_tuple(cls_and_vals, omit_if_default: bool):
233241
234242@settings (suppress_health_check = [HealthCheck .filter_too_much , HealthCheck .too_slow ])
235243@given (
236- simple_typed_classes (defaults = False , newtypes = False ),
237- simple_typed_classes (defaults = False , newtypes = False ),
244+ simple_typed_classes (defaults = False , newtypes = False , allow_nan = False ),
245+ simple_typed_classes (defaults = False , newtypes = False , allow_nan = False ),
238246 unstructure_strats ,
239247)
240248def test_union_field_roundtrip (cl_and_vals_a , cl_and_vals_b , strat ):
@@ -278,8 +286,8 @@ def handler(obj, _):
278286@pytest .mark .skipif (not is_py310_plus , reason = "3.10+ union syntax" )
279287@settings (suppress_health_check = [HealthCheck .filter_too_much , HealthCheck .too_slow ])
280288@given (
281- simple_typed_classes (defaults = False , newtypes = False ),
282- simple_typed_classes (defaults = False , newtypes = False ),
289+ simple_typed_classes (defaults = False , newtypes = False , allow_nan = False ),
290+ simple_typed_classes (defaults = False , newtypes = False , allow_nan = False ),
283291 unstructure_strats ,
284292)
285293def test_310_union_field_roundtrip (cl_and_vals_a , cl_and_vals_b , strat ):
@@ -320,7 +328,7 @@ def handler(obj, _):
320328 assert inst == converter .structure (unstructured , C )
321329
322330
323- @given (simple_typed_classes (defaults = False ))
331+ @given (simple_typed_classes (defaults = False , allow_nan = False ))
324332def test_optional_field_roundtrip (cl_and_vals ):
325333 """
326334 Classes with optional fields can be unstructured and structured.
@@ -342,7 +350,7 @@ class C:
342350
343351
344352@pytest .mark .skipif (not is_py310_plus , reason = "3.10+ union syntax" )
345- @given (simple_typed_classes (defaults = False ))
353+ @given (simple_typed_classes (defaults = False , allow_nan = False ))
346354def test_310_optional_field_roundtrip (cl_and_vals ):
347355 """
348356 Classes with optional fields can be unstructured and structured.
@@ -363,7 +371,7 @@ class C:
363371 assert inst == converter .structure (unstructured , C )
364372
365373
366- @given (simple_typed_classes (defaults = True ))
374+ @given (simple_typed_classes (defaults = True , allow_nan = False ))
367375def test_omit_default_roundtrip (cl_and_vals ):
368376 """
369377 Omit default on the converter works.
0 commit comments