From 817b3bbc76aecad7de24fbf24e723e5d10dfa2c3 Mon Sep 17 00:00:00 2001 From: Christian Ledermann Date: Sat, 9 Nov 2024 13:44:51 +0000 Subject: [PATCH] improve uri text strategy --- tests/hypothesis/strategies.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/hypothesis/strategies.py b/tests/hypothesis/strategies.py index 3190d6b2..e987ec2b 100644 --- a/tests/hypothesis/strategies.py +++ b/tests/hypothesis/strategies.py @@ -30,6 +30,7 @@ from fastkml.times import KmlDateTime ID_TEXT: Final = string.ascii_letters + string.digits + ".-_" + nc_name = partial( st.from_regex, regex=re.compile(r"^[A-Za-z_][\w.-]*$"), @@ -43,24 +44,26 @@ alphabet=f"{string.ascii_letters}-{string.digits}", fullmatch=True, ) + media_types = partial( st.from_regex, regex=re.compile(r"^[a-zA-Z0-9-]+/[a-zA-Z0-9-]+$"), alphabet=f"{string.ascii_letters}/-{string.digits}", fullmatch=True, ) + xml_text = partial( st.text, alphabet=st.characters(min_codepoint=1, blacklist_categories=("Cc", "Cs")), ) + uri_text = partial( st.from_regex, - regex=re.compile(r"^[a-zA-Z][a-zA-Z0-9+\-.]*://.+$"), - alphabet=f"{string.ascii_letters}{string.digits}+-.:/", + regex=re.compile(r"^[a-zA-Z][a-zA-Z0-9+.-]*://([^/?#]*)([^#]*)(#.*)?$"), + alphabet=f"{string.ascii_letters}{string.digits}+-._~:/?#[]@!$&'()*+,;=%", fullmatch=True, ) - kml_datetimes = partial( st.builds, KmlDateTime,