Skip to content

Commit 5a61f64

Browse files
committed
Add test for time
1 parent 062d1c6 commit 5a61f64

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

tests/validators/test_time.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,27 @@ def test_time_json(py_and_json: PyAndJson, input_value, expected):
8080
assert output == expected
8181

8282

83+
def test_time_error_microseconds_overflow(py_and_json: PyAndJson) -> None:
84+
v = py_and_json(core_schema.time_schema(microseconds_precision='error'))
85+
86+
with pytest.raises(ValidationError) as exc_info:
87+
v.validate_test('00:00:00.1234567')
88+
89+
# insert_assert(exc_info.value.errors(include_url=False))
90+
assert exc_info.value.errors(include_url=False) == [
91+
{
92+
'type': 'time_parsing',
93+
'loc': (),
94+
'msg': 'Input should be in a valid time format, second fraction value is more than 6 digits long',
95+
'input': '00:00:00.1234567',
96+
'ctx': {'error': 'second fraction value is more than 6 digits long'},
97+
}
98+
]
99+
100+
# insert_assert(v.validate_test('00:00:00.123456'))
101+
assert v.validate_test('00:00:00.123456') == time(0, 0, 0, 123456)
102+
103+
83104
@pytest.mark.parametrize(
84105
'input_value,expected',
85106
[

0 commit comments

Comments
 (0)