The perfectly valid urls in the test case below are resolved correctly by most contemporary browsers (and – curiously – wget, but not curl), but do not pass marshmallows Url field validation. Which i think they should, because they do show up in real world data.
I'm not sure how to best approach the problem.
"""Tests for marshmallow.validate"""
import pytest
from marshmallow import validate
@pytest.mark.parametrize(
"valid_url",
[
"http://www.kunstkontor-nürnberg.de",
"http://💩.la",
],
)
def test_url_absolute_valid(valid_url):
validator = validate.URL(relative=False)
assert validator(valid_url) == valid_url
We may want to consider using urllib.
https://docs.python.org/3/library/urllib.parse.html#module-urllib.parse
Most helpful comment
We may want to consider using
urllib.https://docs.python.org/3/library/urllib.parse.html#module-urllib.parse