()
| 1116 | |
| 1117 | |
| 1118 | def test_after_validator() -> None: |
| 1119 | def remove_trailing_slash(url: AnyUrl) -> str: |
| 1120 | """Custom url -> str transformer that removes trailing slash.""" |
| 1121 | return str(url._url).rstrip('/') |
| 1122 | |
| 1123 | HttpUrl = Annotated[ |
| 1124 | AnyUrl, |
| 1125 | UrlConstraints(allowed_schemes=['http', 'https']), |
| 1126 | AfterValidator(lambda url: remove_trailing_slash(url)), |
| 1127 | ] |
| 1128 | ta = TypeAdapter(HttpUrl) |
| 1129 | assert ta.validate_python('https://example.com/') == 'https://example.com' |
| 1130 | |
| 1131 | |
| 1132 | def test_serialize_as_any() -> None: |
nothing calls this directly
no test coverage detected