diff --git a/src/hyperlink/hypothesis.py b/src/hyperlink/hypothesis.py index 4ab987e..3be47da 100644 --- a/src/hyperlink/hypothesis.py +++ b/src/hyperlink/hypothesis.py @@ -31,7 +31,7 @@ from . import DecodedURL, EncodedURL - from hypothesis import assume + from hypothesis import reject from hypothesis.strategies import ( composite, integers, @@ -137,7 +137,7 @@ def idna_text(draw, min_size=1, max_size=None): try: idna_encode(result) except IDNAError: - assume(False) + reject() return result @@ -198,7 +198,7 @@ def hostname_labels(draw, allow_idn=True): try: check_label(label) except UnicodeError: # pragma: no cover (not always drawn) - assume(False) + reject() return label @@ -318,4 +318,8 @@ def decoded_urls(draw): Call the L{EncodedURL.to_uri} method on each URL to get an HTTP protocol-friendly URI. """ - return DecodedURL(draw(encoded_urls())) + encoded_url = draw(encoded_urls()) + try: + return DecodedURL(encoded_url) + except UnicodeDecodeError: + reject() diff --git a/tox.ini b/tox.ini index 8865d17..56caefe 100644 --- a/tox.ini +++ b/tox.ini @@ -93,7 +93,15 @@ basepython = {[default]basepython} skip_install = True deps = + # Pin black and all of its dependencies so an incompatible release of one + # of them doesn't break this environment. + appdirs==1.4.4 black==21.7b0 + click==7.1.2 + mypy-extensions==0.4.3 + pathspec==0.9.0 + regex==2022.8.17 + tomli==1.2.3 setenv = BLACK_LINT_ARGS=--check