Skip to content

Commit 229f147

Browse files
committed
Avoid composite for fixed IDNA test data
1 parent 978f2e6 commit 229f147

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

src/hyperlink/test/test_hypothesis.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,13 @@
1919
from mock import patch # type: ignore[misc]
2020

2121
from hypothesis import given, settings
22-
from hypothesis.strategies import SearchStrategy, data
22+
from hypothesis.strategies import SearchStrategy, data, just
2323

2424
from idna import IDNAError, check_label, encode as idna_encode
2525

2626
from .common import HyperlinkTestCase
2727
from .. import DecodedURL, EncodedURL
2828
from ..hypothesis import (
29-
DrawCallable,
30-
composite,
3129
decoded_urls,
3230
encoded_urls,
3331
hostname_labels,
@@ -102,15 +100,16 @@ def test_hostname_labels_long_idn_punycode(self, data):
102100
that encoded to punycode ends up as longer than allowed.
103101
"""
104102

105-
@composite
106-
def mock_idna_text(draw, min_size, max_size):
107-
# type: (DrawCallable, int, int) -> Text
103+
def mock_idna_text(min_size, max_size):
104+
# type: (int, int) -> SearchStrategy[Text]
108105
# We want a string that does not exceed max_size, but when
109106
# encoded to punycode, does exceed max_size.
110107
# So use a unicode character that is larger when encoded,
111108
# "á" being a great example, and use it max_size times, which
112109
# will be max_size * 3 in size when encoded.
113-
return u"\N{LATIN SMALL LETTER A WITH ACUTE}" * max_size
110+
return just(
111+
u"\N{LATIN SMALL LETTER A WITH ACUTE}" * max_size
112+
)
114113

115114
with patch("hyperlink.hypothesis.idna_text", mock_idna_text):
116115
label = data.draw(hostname_labels())

0 commit comments

Comments
 (0)