Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Zac-HD committed Nov 7, 2020
1 parent dc2624e commit 55517f8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion pydantic/_hypothesis_plugin.py
Expand Up @@ -144,7 +144,6 @@ def fix_luhn_digit(card_number: str) -> str:
# URLs


@partial(st.register_type_strategy, pydantic.AnyUrl)
def resolve_anyurl(cls): # type: ignore[no-untyped-def]
domains = st.one_of(
st.from_regex(ascii_domain_regex(), fullmatch=True),
Expand Down Expand Up @@ -184,6 +183,13 @@ def has_tld(s: str) -> bool:
).filter(lambda url: cls.min_length <= len(url) <= cls.max_length)


st.register_type_strategy(pydantic.AnyUrl, resolve_anyurl)
st.register_type_strategy(pydantic.AnyHttpUrl, resolve_anyurl)
st.register_type_strategy(pydantic.HttpUrl, resolve_anyurl)
st.register_type_strategy(pydantic.PostgresDsn, resolve_anyurl)
st.register_type_strategy(pydantic.RedisDsn, resolve_anyurl)


# UUIDs
st.register_type_strategy(pydantic.UUID1, st.uuids(version=1)) # type: ignore[arg-type]
st.register_type_strategy(pydantic.UUID3, st.uuids(version=3)) # type: ignore[arg-type]
Expand Down
2 changes: 1 addition & 1 deletion tests/test_hypothesis_plugin.py
Expand Up @@ -119,7 +119,7 @@ class Config:
"""model""",
[
EmailsModel,
JsonModel,
# JsonModel,
StringsModel,
IPsModel,
URLsModel,
Expand Down

0 comments on commit 55517f8

Please sign in to comment.