From 55517f8c3672774b0282a8ea9d63fe61e15f29d5 Mon Sep 17 00:00:00 2001 From: Zac-HD Date: Sat, 7 Nov 2020 19:11:10 +1100 Subject: [PATCH] WIP --- pydantic/_hypothesis_plugin.py | 8 +++++++- tests/test_hypothesis_plugin.py | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/pydantic/_hypothesis_plugin.py b/pydantic/_hypothesis_plugin.py index 2127f217096..ed454a1a2e8 100644 --- a/pydantic/_hypothesis_plugin.py +++ b/pydantic/_hypothesis_plugin.py @@ -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), @@ -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] diff --git a/tests/test_hypothesis_plugin.py b/tests/test_hypothesis_plugin.py index ac89b6d7633..f76b4d792e3 100644 --- a/tests/test_hypothesis_plugin.py +++ b/tests/test_hypothesis_plugin.py @@ -119,7 +119,7 @@ class Config: """model""", [ EmailsModel, - JsonModel, + # JsonModel, StringsModel, IPsModel, URLsModel,