From 229f147ea9f2878b27777409e8fc731495e6d040 Mon Sep 17 00:00:00 2001 From: Miro <200482516+Mirochill@users.noreply.github.com> Date: Tue, 19 May 2026 14:43:33 +0200 Subject: [PATCH] Avoid composite for fixed IDNA test data --- src/hyperlink/test/test_hypothesis.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/hyperlink/test/test_hypothesis.py b/src/hyperlink/test/test_hypothesis.py index 776ed7b7..8ee24933 100644 --- a/src/hyperlink/test/test_hypothesis.py +++ b/src/hyperlink/test/test_hypothesis.py @@ -19,15 +19,13 @@ from mock import patch # type: ignore[misc] from hypothesis import given, settings - from hypothesis.strategies import SearchStrategy, data + from hypothesis.strategies import SearchStrategy, data, just from idna import IDNAError, check_label, encode as idna_encode from .common import HyperlinkTestCase from .. import DecodedURL, EncodedURL from ..hypothesis import ( - DrawCallable, - composite, decoded_urls, encoded_urls, hostname_labels, @@ -102,15 +100,16 @@ def test_hostname_labels_long_idn_punycode(self, data): that encoded to punycode ends up as longer than allowed. """ - @composite - def mock_idna_text(draw, min_size, max_size): - # type: (DrawCallable, int, int) -> Text + def mock_idna_text(min_size, max_size): + # type: (int, int) -> SearchStrategy[Text] # We want a string that does not exceed max_size, but when # encoded to punycode, does exceed max_size. # So use a unicode character that is larger when encoded, # "รก" being a great example, and use it max_size times, which # will be max_size * 3 in size when encoded. - return u"\N{LATIN SMALL LETTER A WITH ACUTE}" * max_size + return just( + u"\N{LATIN SMALL LETTER A WITH ACUTE}" * max_size + ) with patch("hyperlink.hypothesis.idna_text", mock_idna_text): label = data.draw(hostname_labels())