Skip to content

Commit 193f5d7

Browse files
Uprev speedate (#1244)
1 parent da16140 commit 193f5d7

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ strum_macros = "0.26.1"
3434
serde_json = {version = "1.0.114", features = ["arbitrary_precision", "preserve_order"]}
3535
enum_dispatch = "0.3.8"
3636
serde = { version = "1.0.196", features = ["derive"] }
37-
speedate = "0.13.0"
37+
speedate = "0.14.0"
3838
smallvec = "1.13.1"
3939
ahash = "0.8.10"
4040
url = "2.5.0"

tests/serializers/test_any.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def test_set_member_db(any_serializer):
105105
(datetime(2032, 1, 1, 1, 1), b'"2032-01-01T01:01:00"'),
106106
(date(2022, 12, 3), b'"2022-12-03"'),
107107
(time(12, 30, 45), b'"12:30:45"'),
108-
(timedelta(hours=2), b'"PT7200S"'),
108+
(timedelta(hours=2), b'"PT2H"'),
109109
(MyDataclass(1, 'foo', 2), b'{"a":1,"b":"foo"}'),
110110
(MyModel(a=1, b='foo'), b'{"a":1,"b":"foo"}'),
111111
([MyDataclass(1, 'a', 2), MyModel(a=2, b='b')], b'[{"a":1,"b":"a"},{"a":2,"b":"b"}]'),
@@ -164,8 +164,8 @@ def test_any_with_date_serializer():
164164
def test_any_with_timedelta_serializer():
165165
s = SchemaSerializer(core_schema.any_schema(serialization={'type': 'timedelta'}))
166166
assert s.to_python(timedelta(hours=2)) == timedelta(hours=2)
167-
assert s.to_python(timedelta(hours=2), mode='json') == 'PT7200S'
168-
assert s.to_json(timedelta(hours=2)) == b'"PT7200S"'
167+
assert s.to_python(timedelta(hours=2), mode='json') == 'PT2H'
168+
assert s.to_json(timedelta(hours=2)) == b'"PT2H"'
169169

170170
with pytest.warns(UserWarning) as warning_info:
171171
assert s.to_python(b'bang', mode='json') == 'bang'

tests/serializers/test_timedelta.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ def test_timedelta():
1414
v = SchemaSerializer(core_schema.timedelta_schema())
1515
assert v.to_python(timedelta(days=2, hours=3, minutes=4)) == timedelta(days=2, hours=3, minutes=4)
1616

17-
assert v.to_python(timedelta(days=2, hours=3, minutes=4), mode='json') == 'P2DT11040S'
18-
assert v.to_json(timedelta(days=2, hours=3, minutes=4)) == b'"P2DT11040S"'
17+
assert v.to_python(timedelta(days=2, hours=3, minutes=4), mode='json') == 'P2DT3H4M'
18+
assert v.to_json(timedelta(days=2, hours=3, minutes=4)) == b'"P2DT3H4M"'
1919

2020
with pytest.warns(
2121
UserWarning, match='Expected `timedelta` but got `int` - serialized value may not be as expected'
@@ -39,14 +39,14 @@ def test_timedelta_float():
3939
def test_timedelta_key():
4040
v = SchemaSerializer(core_schema.dict_schema(core_schema.timedelta_schema(), core_schema.int_schema()))
4141
assert v.to_python({timedelta(days=2, hours=3, minutes=4): 1}) == {timedelta(days=2, hours=3, minutes=4): 1}
42-
assert v.to_python({timedelta(days=2, hours=3, minutes=4): 1}, mode='json') == {'P2DT11040S': 1}
43-
assert v.to_json({timedelta(days=2, hours=3, minutes=4): 1}) == b'{"P2DT11040S":1}'
42+
assert v.to_python({timedelta(days=2, hours=3, minutes=4): 1}, mode='json') == {'P2DT3H4M': 1}
43+
assert v.to_json({timedelta(days=2, hours=3, minutes=4): 1}) == b'{"P2DT3H4M":1}'
4444

4545

4646
@pytest.mark.skipif(not pandas, reason='pandas not installed')
4747
def test_pandas():
4848
v = SchemaSerializer(core_schema.timedelta_schema())
4949
d = pandas.Timestamp('2023-01-01T02:00:00Z') - pandas.Timestamp('2023-01-01T00:00:00Z')
5050
assert v.to_python(d) == d
51-
assert v.to_python(d, mode='json') == 'PT7200S'
52-
assert v.to_json(d) == b'"PT7200S"'
51+
assert v.to_python(d, mode='json') == 'PT2H'
52+
assert v.to_json(d) == b'"PT2H"'

0 commit comments

Comments
 (0)