Skip to content

Commit 83c1fee

Browse files
committed
basic tests
1 parent 932eaf0 commit 83c1fee

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

tests/test_errors.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ def multi_raise_py_error(v: Any) -> Any:
551551
s2.validate_python('anything')
552552

553553
cause_group = exc_info.value.__cause__
554-
assert isinstance(cause_group, BaseExceptionGroup) # noqa: F821
554+
assert isinstance(cause_group, BaseExceptionGroup)
555555
assert len(cause_group.exceptions) == 1
556556

557557
cause = cause_group.exceptions[0]
@@ -576,7 +576,7 @@ def outer_raise_py_error(v: Any) -> Any:
576576
with pytest.raises(ValidationError) as exc_info:
577577
s3.validate_python('anything')
578578

579-
assert isinstance(exc_info.value.__cause__, BaseExceptionGroup) # noqa: F821
579+
assert isinstance(exc_info.value.__cause__, BaseExceptionGroup)
580580
assert len(exc_info.value.__cause__.exceptions) == 1
581581
cause = exc_info.value.__cause__.exceptions[0]
582582
assert cause.__notes__ and cause.__notes__[-1].startswith('\nPydantic: ')
@@ -585,7 +585,7 @@ def outer_raise_py_error(v: Any) -> Any:
585585
assert isinstance(subcause, ValidationError)
586586

587587
cause_group = subcause.__cause__
588-
assert isinstance(cause_group, BaseExceptionGroup) # noqa: F821
588+
assert isinstance(cause_group, BaseExceptionGroup)
589589
assert len(cause_group.exceptions) == 1
590590

591591
cause = cause_group.exceptions[0]

tests/validators/test_url.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1305,3 +1305,19 @@ def test_url_build() -> None:
13051305
)
13061306
assert url == Url('postgresql://testuser:[email protected]:5432/database?sslmode=require#test')
13071307
assert str(url) == 'postgresql://testuser:[email protected]:5432/database?sslmode=require#test'
1308+
1309+
1310+
def test_url_subclass() -> None:
1311+
class UrlSubclass(Url):
1312+
pass
1313+
1314+
validator = SchemaValidator(core_schema.url_schema(cls=UrlSubclass))
1315+
assert isinstance(validator.validate_python('http://example.com'), UrlSubclass)
1316+
1317+
1318+
def test_multi_host_url_subclass() -> None:
1319+
class MultiHostUrlSubclass(MultiHostUrl):
1320+
pass
1321+
1322+
validator = SchemaValidator(core_schema.multi_host_url_schema(cls=MultiHostUrlSubclass))
1323+
assert isinstance(validator.validate_python('http://example.com'), MultiHostUrlSubclass)

0 commit comments

Comments
 (0)