Skip to content

Commit

Permalink
improve uri text strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
cleder committed Nov 9, 2024
1 parent f4d4d7c commit 817b3bb
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions tests/hypothesis/strategies.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.-]*$"),
Expand All @@ -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,
Expand Down

0 comments on commit 817b3bb

Please sign in to comment.