File: deserialization_pass_through.py

package info (click to toggle)
python-apischema 0.18.3-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 1,608 kB
  • sloc: python: 15,266; sh: 7; makefile: 7
file content (14 lines) | stat: -rw-r--r-- 457 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
from datetime import datetime, timedelta

from apischema import deserialize

start, end = datetime.now(), datetime.now() + timedelta(1)
assert deserialize(
    tuple[datetime, datetime], [start, end], pass_through={datetime}
) == (start, end)
# Passing through types can also be deserialized normally from JSON types
assert deserialize(
    tuple[datetime, datetime],
    [start.isoformat(), end.isoformat()],
    pass_through={datetime},
) == (start, end)