Skip to content

Commit eef8902

Browse files
committed
fix tests
1 parent 9d7475c commit eef8902

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

tests/serializers/test_model.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import dataclasses
22
import json
33
import platform
4+
import sys
45
import warnings
56
from random import randint
6-
from typing import Any, ClassVar, Dict, Never
7+
from typing import Any, ClassVar, Dict
78

89
try:
910
from functools import cached_property
@@ -1154,7 +1155,10 @@ class BModel(BasicModel): ...
11541155
s.to_python(value)
11551156

11561157

1158+
@pytest.mark.skipif(sys.version_info < (3, 11), reason='typing.Never was introduced in 3.11')
11571159
def test_never():
1160+
from typing import Never
1161+
11581162
class MyModel:
11591163
a: int
11601164
b: Never

tests/test_schema_functions.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,7 @@ def args(*args, **kwargs):
291291
(core_schema.decimal_schema, args(), {'type': 'decimal'}),
292292
(core_schema.decimal_schema, args(multiple_of=5, gt=1.2), {'type': 'decimal', 'multiple_of': 5, 'gt': 1.2}),
293293
(core_schema.complex_schema, args(), {'type': 'complex'}),
294+
(core_schema.never_schema, args(), {'type': 'never'}),
294295
(core_schema.invalid_schema, args(), {'type': 'invalid'}),
295296
]
296297

tests/validators/test_never.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Never
1+
import sys
22

33
import pytest
44

@@ -16,7 +16,10 @@ def test_python_never():
1616
assert v.validate_python(PydanticUndefined) is PydanticUndefined
1717

1818

19+
@pytest.mark.skipif(sys.version_info < (3, 11), reason='typing.Never was introduced in 3.11')
1920
def test_json_never():
21+
from typing import Never
22+
2023
v = SchemaValidator(core_schema.never_schema())
2124
with pytest.raises(ValidationError) as exc_info:
2225
v.validate_json('null')

0 commit comments

Comments
 (0)