MCPcopy
hub / github.com/pydantic/pydantic / test_url_ok

Function test_url_ok

pydantic-core/tests/validators/test_url.py:13–30  ·  view source on GitHub ↗
(py_and_json: PyAndJson)

Source from the content-addressed store, hash-verified

11
12
13def test_url_ok(py_and_json: PyAndJson):
14 v = py_and_json(core_schema.url_schema())
15 url = v.validate_test('https://example.com/foo/bar?baz=qux#quux')
16
17 assert isinstance(url, Url)
18 assert str(url) == 'https://example.com/foo/bar?baz=qux#quux'
19 assert repr(url) == "Url('https://example.com/foo/bar?baz=qux#quux')"
20 assert url.unicode_string() == 'https://example.com/foo/bar?baz=qux#quux'
21 assert url.scheme == 'https'
22 assert url.host == 'example.com'
23 assert url.unicode_host() == 'example.com'
24 assert url.path == '/foo/bar'
25 assert url.query == 'baz=qux'
26 assert url.query_params() == [('baz', 'qux')]
27 assert url.fragment == 'quux'
28 assert url.username is None
29 assert url.password is None
30 assert url.port == 443
31
32
33def test_url_from_constructor_ok():

Callers

nothing calls this directly

Calls 6

py_and_jsonFunction · 0.85
url_schemaMethod · 0.80
validate_testMethod · 0.80
unicode_hostMethod · 0.80
unicode_stringMethod · 0.45
query_paramsMethod · 0.45

Tested by

no test coverage detected