@@ -126,7 +126,7 @@ def test_date_marshaller(given_input, expected_output):
126126 expected_output = datetime .datetime (1969 , 12 , 31 ).isoformat (),
127127 ),
128128)
129- def test_datetime_unmarshaller (given_input , expected_output ):
129+ def test_datetime_marshaller (given_input , expected_output ):
130130 # Given
131131 given_marshaller = routines .DateTimeMarshaller (datetime .datetime , {})
132132 # When
@@ -141,7 +141,7 @@ def test_datetime_unmarshaller(given_input, expected_output):
141141 expected_output = "00:00:00+00:00" ,
142142 ),
143143)
144- def test_time_unmarshaller (given_input , expected_output ):
144+ def test_time_marshaller (given_input , expected_output ):
145145 # Given
146146 given_marshaller = routines .TimeMarshaller (datetime .time , {})
147147 # When
@@ -153,7 +153,7 @@ def test_time_unmarshaller(given_input, expected_output):
153153@pytest .mark .suite (
154154 timedelta = dict (given_input = datetime .timedelta (seconds = 1 ), expected_output = "PT1S" ),
155155)
156- def test_timedelta_unmarshaller (given_input , expected_output ):
156+ def test_timedelta_marshaller (given_input , expected_output ):
157157 # Given
158158 given_marshaller = routines .TimeDeltaMarshaller (datetime .timedelta , {})
159159 # When
@@ -187,7 +187,7 @@ def test_mapping_marshaller(given_input, expected_output):
187187 expected_output = ["field" , "value" ],
188188 ),
189189)
190- def test_iterable_unmarshaller (given_input , expected_output ):
190+ def test_iterable_marshaller (given_input , expected_output ):
191191 # Given
192192 given_marshaller = routines .IterableMarshaller (typing .Iterable , {})
193193 # When
@@ -259,8 +259,26 @@ def test_literal_marshaller(given_input, given_literal, given_context, expected_
259259 },
260260 expected_output = 1 ,
261261 ),
262+ optional_date_none = dict (
263+ given_input = None ,
264+ given_union = typing .Optional [datetime .date ],
265+ given_context = {
266+ datetime .date : routines .DateMarshaller (datetime .date , {}),
267+ type (None ): routines .NoOpMarshaller (type (None ), {}),
268+ },
269+ expected_output = None ,
270+ ),
271+ optional_date_date = dict (
272+ given_input = datetime .date .today (),
273+ given_union = typing .Optional [datetime .date ],
274+ given_context = {
275+ datetime .date : routines .DateMarshaller (datetime .date , {}),
276+ type (None ): routines .NoOpMarshaller (type (None ), {}),
277+ },
278+ expected_output = datetime .date .today ().isoformat (),
279+ ),
262280)
263- def test_union_unmarshaller (given_input , given_union , given_context , expected_output ):
281+ def test_union_marshaller (given_input , given_union , given_context , expected_output ):
264282 # Given
265283 given_marshaller = routines .UnionMarshaller (given_union , given_context )
266284 # When
@@ -280,7 +298,7 @@ def test_union_unmarshaller(given_input, given_union, given_context, expected_ou
280298 expected_output = {"field" : 1 },
281299 ),
282300)
283- def test_subscripted_mapping_unmarshaller (
301+ def test_subscripted_mapping_marshaller (
284302 given_input , given_mapping , given_context , expected_output
285303):
286304 # Given
@@ -373,7 +391,7 @@ def test_subscripted_iterable_marshaller(
373391 expected_output = ["field" , 1 ],
374392 ),
375393)
376- def test_fixed_tuple_unmarshaller (
394+ def test_fixed_tuple_marshaller (
377395 given_input , given_tuple , given_context , expected_output
378396):
379397 # Given
@@ -419,7 +437,7 @@ def test_fixed_tuple_unmarshaller(
419437 given_input = models .TDict (field = "data" , value = 1 ),
420438 ),
421439)
422- def test_structured_type_unmarshaller (
440+ def test_structured_type_marshaller (
423441 given_input , given_cls , given_context , expected_output
424442):
425443 # Given
@@ -456,12 +474,12 @@ def test_invalid_union():
456474 given_marshaller (given_value )
457475
458476
459- def test_enum_unmarshaller ():
477+ def test_enum_marshaller ():
460478 # Given
461- given_unmarshaller = routines .EnumMarshaller (models .GivenEnum , {})
479+ given_marshaller = routines .EnumMarshaller (models .GivenEnum , {})
462480 given_value = models .GivenEnum .one
463481 expected_value = models .GivenEnum .one .value
464482 # When
465- unmarshalled = given_unmarshaller (given_value )
483+ unmarshalled = given_marshaller (given_value )
466484 # Then
467485 assert unmarshalled == expected_value
0 commit comments