|
19 | 19 | from mock import patch # type: ignore[misc] |
20 | 20 |
|
21 | 21 | from hypothesis import given, settings |
22 | | - from hypothesis.strategies import SearchStrategy, data |
| 22 | + from hypothesis.strategies import SearchStrategy, data, just |
23 | 23 |
|
24 | 24 | from idna import IDNAError, check_label, encode as idna_encode |
25 | 25 |
|
26 | 26 | from .common import HyperlinkTestCase |
27 | 27 | from .. import DecodedURL, EncodedURL |
28 | 28 | from ..hypothesis import ( |
29 | | - DrawCallable, |
30 | | - composite, |
31 | 29 | decoded_urls, |
32 | 30 | encoded_urls, |
33 | 31 | hostname_labels, |
@@ -102,15 +100,16 @@ def test_hostname_labels_long_idn_punycode(self, data): |
102 | 100 | that encoded to punycode ends up as longer than allowed. |
103 | 101 | """ |
104 | 102 |
|
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] |
108 | 105 | # We want a string that does not exceed max_size, but when |
109 | 106 | # encoded to punycode, does exceed max_size. |
110 | 107 | # So use a unicode character that is larger when encoded, |
111 | 108 | # "á" being a great example, and use it max_size times, which |
112 | 109 | # 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 | + ) |
114 | 113 |
|
115 | 114 | with patch("hyperlink.hypothesis.idna_text", mock_idna_text): |
116 | 115 | label = data.draw(hostname_labels()) |
|
0 commit comments