@@ -286,26 +286,29 @@ def test_pendulum_duration_from_serialized(delta_t_str):
286
286
@pytest .mark .parametrize (
287
287
'duration' ,
288
288
[
289
- ( Duration (months = 1 ) ),
290
- ( Duration (weeks = 1 ) ),
291
- ( Duration (milliseconds = 1 ) ),
292
- ( Duration (microseconds = 1 ) ),
293
- ( Duration (days = 1 ) ),
294
- ( Duration (hours = 1 ) ),
295
- ( Duration (minutes = 1 ) ),
296
- ( Duration (seconds = 1 ) ),
297
- ( Duration (months = 2 , days = 5 ) ),
298
- ( Duration (weeks = 3 , hours = 12 ) ),
299
- ( Duration (days = 10 , minutes = 30 ) ),
300
- ( Duration (weeks = 1 , days = 2 , hours = 3 ) ),
301
- ( Duration (seconds = 30 , milliseconds = 500 ) ),
289
+ Duration (months = 1 ),
290
+ Duration (weeks = 1 ),
291
+ Duration (milliseconds = 1 ),
292
+ Duration (microseconds = 1 ),
293
+ Duration (days = 1 ),
294
+ Duration (hours = 1 ),
295
+ Duration (minutes = 1 ),
296
+ Duration (seconds = 1 ),
297
+ Duration (months = 2 , days = 5 ),
298
+ Duration (weeks = 3 , hours = 12 ),
299
+ Duration (days = 10 , minutes = 30 ),
300
+ Duration (weeks = 1 , days = 2 , hours = 3 ),
301
+ Duration (seconds = 30 , milliseconds = 500 ),
302
302
],
303
303
)
304
304
def test_pendulum_duration_serialization_roundtrip (duration ):
305
305
adapter = TypeAdapter (Duration )
306
- serialized = adapter .dump_python (duration )
307
- deserialized = TypeAdapter .validate_python (adapter , serialized )
308
- assert deserialized == duration
306
+ python_serialized = adapter .dump_python (duration )
307
+ json_serialized = adapter .dump_json (duration )
308
+ deserialized = TypeAdapter .validate_json (adapter , json_serialized )
309
+ assert deserialized == python_serialized == duration
310
+ assert deserialized .years == python_serialized .years == duration .years
311
+ assert deserialized .months == python_serialized .months == duration .months
309
312
310
313
311
314
def get_invalid_dt_common ():
0 commit comments