@@ -92,8 +92,30 @@ def test_pendulum_date_existing_instance(instance):
92
92
[
93
93
pendulum .duration (days = 42 , hours = 13 , minutes = 37 ),
94
94
pendulum .duration (days = - 42 , hours = 13 , minutes = 37 ),
95
+ pendulum .duration (weeks = 97 ),
96
+ pendulum .duration (days = 463 ),
97
+ pendulum .duration (milliseconds = 90122 ),
98
+ pendulum .duration (microseconds = 90122 ),
99
+ pendulum .duration (
100
+ years = 2 ,
101
+ months = 3 ,
102
+ weeks = 19 ,
103
+ days = 1 ,
104
+ hours = 25 ,
105
+ seconds = 732 ,
106
+ milliseconds = 123 ,
107
+ microseconds = 1324 ,
108
+ ),
95
109
timedelta (days = 42 , hours = 13 , minutes = 37 ),
96
110
timedelta (days = - 42 , hours = 13 , minutes = 37 ),
111
+ timedelta (
112
+ weeks = 19 ,
113
+ days = 1 ,
114
+ hours = 25 ,
115
+ seconds = 732 ,
116
+ milliseconds = 123 ,
117
+ microseconds = 1324 ,
118
+ ),
97
119
],
98
120
)
99
121
def test_duration_timedelta__existing_instance (instance ):
@@ -227,7 +249,11 @@ def test_pendulum_dt_from_str_unix_timestamp_is_utc(dt):
227
249
228
250
@pytest .mark .parametrize (
229
251
'd' ,
230
- [pendulum .now ().date ().isoformat (), pendulum .now ().to_w3c_string (), pendulum .now ().to_iso8601_string ()],
252
+ [
253
+ pendulum .now ().date ().isoformat (),
254
+ pendulum .now ().to_w3c_string (),
255
+ pendulum .now ().to_iso8601_string (),
256
+ ],
231
257
)
232
258
def test_pendulum_date_from_serialized (d ):
233
259
"""Verifies that building an instance from serialized, well-formed strings decode properly."""
@@ -308,7 +334,10 @@ def test_pendulum_dt_non_strict_malformed(dt):
308
334
DtModelNotStrict (dt = dt )
309
335
310
336
311
- @pytest .mark .parametrize ('invalid_value' , [None , 'malformed' , pendulum .today ().to_iso8601_string ()[:5 ], 'P10Y10M10D' ])
337
+ @pytest .mark .parametrize (
338
+ 'invalid_value' ,
339
+ [None , 'malformed' , pendulum .today ().to_iso8601_string ()[:5 ], 'P10Y10M10D' ],
340
+ )
312
341
def test_pendulum_date_malformed (invalid_value ):
313
342
"""Verifies that the instance fails to validate if malformed date are passed."""
314
343
with pytest .raises (ValidationError ):
@@ -317,7 +346,14 @@ def test_pendulum_date_malformed(invalid_value):
317
346
318
347
@pytest .mark .parametrize (
319
348
'delta_t' ,
320
- [None , 'malformed' , pendulum .today ().to_iso8601_string ()[:5 ], 42 , '12m' , '2021-01-01T12:00:00' ],
349
+ [
350
+ None ,
351
+ 'malformed' ,
352
+ pendulum .today ().to_iso8601_string ()[:5 ],
353
+ 42 ,
354
+ '12m' ,
355
+ '2021-01-01T12:00:00' ,
356
+ ],
321
357
)
322
358
def test_pendulum_duration_malformed (delta_t ):
323
359
"""Verifies that the instance fails to validate if malformed durations are passed."""
@@ -344,3 +380,9 @@ def test_date_type_adapter(input_type: type, value, is_instance: type):
344
380
assert type (validated ) is input_type
345
381
assert isinstance (validated , input_type )
346
382
assert isinstance (validated , is_instance )
383
+
384
+
385
+ def test_pendulum_duration_months_are_preserved ():
386
+ m = DurationModel (delta_t = pendulum .Duration (months = 1 ))
387
+
388
+ assert m .delta_t .months == 1
0 commit comments