File: test_int_as_float.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 (11 lines) | stat: -rw-r--r-- 352 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
import pytest

from apischema import ValidationError, deserialize, schema


def test_int_as_float():
    assert deserialize(float, 42) == 42.0
    assert type(deserialize(float, 42)) == float
    assert deserialize(float, 42, schema=schema(min=0)) == 42.0
    with pytest.raises(ValidationError):
        deserialize(float, -1.0, schema=schema(min=0))