hypothesis 6.135.8__py3-none-any.whl → 6.135.9__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- hypothesis/extra/_patching.py +42 -17
- hypothesis/internal/constants_ast.py +5 -1
- hypothesis/version.py +1 -1
- {hypothesis-6.135.8.dist-info → hypothesis-6.135.9.dist-info}/METADATA +1 -1
- {hypothesis-6.135.8.dist-info → hypothesis-6.135.9.dist-info}/RECORD +9 -9
- {hypothesis-6.135.8.dist-info → hypothesis-6.135.9.dist-info}/WHEEL +0 -0
- {hypothesis-6.135.8.dist-info → hypothesis-6.135.9.dist-info}/entry_points.txt +0 -0
- {hypothesis-6.135.8.dist-info → hypothesis-6.135.9.dist-info}/licenses/LICENSE.txt +0 -0
- {hypothesis-6.135.8.dist-info → hypothesis-6.135.9.dist-info}/top_level.txt +0 -0
hypothesis/extra/_patching.py
CHANGED
@@ -45,11 +45,11 @@ try:
|
|
45
45
|
except ImportError:
|
46
46
|
black = None # type: ignore
|
47
47
|
|
48
|
-
HEADER =
|
48
|
+
HEADER = """\
|
49
49
|
From HEAD Mon Sep 17 00:00:00 2001
|
50
|
-
From:
|
51
|
-
Date: {
|
52
|
-
Subject: [PATCH] {
|
50
|
+
From: {author}
|
51
|
+
Date: {when:%a, %d %b %Y %H:%M:%S}
|
52
|
+
Subject: [PATCH] {msg}
|
53
53
|
|
54
54
|
---
|
55
55
|
"""
|
@@ -165,20 +165,44 @@ def get_patch_for(
|
|
165
165
|
*,
|
166
166
|
strip_via: tuple[str, ...] = (),
|
167
167
|
) -> Optional[tuple[str, str, str]]:
|
168
|
-
# Skip this if we're unable to find the location
|
168
|
+
# Skip this if we're unable to find the location of this function.
|
169
169
|
try:
|
170
170
|
module = sys.modules[func.__module__]
|
171
|
-
|
172
|
-
before = inspect.getsource(func)
|
171
|
+
file_path = Path(module.__file__) # type: ignore
|
173
172
|
except Exception:
|
174
173
|
return None
|
175
174
|
|
175
|
+
fname = (
|
176
|
+
file_path.relative_to(Path.cwd())
|
177
|
+
if file_path.is_relative_to(Path.cwd())
|
178
|
+
else file_path
|
179
|
+
)
|
180
|
+
patch = _get_patch_for(
|
181
|
+
func, examples, strip_via=strip_via, namespace=module.__dict__
|
182
|
+
)
|
183
|
+
if patch is None:
|
184
|
+
return None
|
185
|
+
|
186
|
+
(before, after) = patch
|
187
|
+
return (str(fname), before, after)
|
188
|
+
|
189
|
+
|
190
|
+
# split out for easier testing of patches in hypofuzz, where the function to
|
191
|
+
# apply the patch to may not be loaded in sys.modules.
|
192
|
+
def _get_patch_for(
|
193
|
+
func: Any,
|
194
|
+
examples: Sequence[tuple[str, str]],
|
195
|
+
*,
|
196
|
+
strip_via: tuple[str, ...] = (),
|
197
|
+
namespace: dict[str, Any],
|
198
|
+
) -> Optional[tuple[str, str]]:
|
199
|
+
try:
|
200
|
+
before = inspect.getsource(func)
|
201
|
+
except Exception: # pragma: no cover
|
202
|
+
return None
|
203
|
+
|
176
204
|
modules_in_test_scope = sorted(
|
177
|
-
(
|
178
|
-
(k, v)
|
179
|
-
for (k, v) in module.__dict__.items()
|
180
|
-
if isinstance(v, types.ModuleType)
|
181
|
-
),
|
205
|
+
((k, v) for (k, v) in namespace.items() if isinstance(v, types.ModuleType)),
|
182
206
|
key=lambda kv: len(kv[1].__name__),
|
183
207
|
)
|
184
208
|
|
@@ -204,7 +228,7 @@ def get_patch_for(
|
|
204
228
|
isinstance(anode, ast.Name)
|
205
229
|
and isinstance(anode.ctx, ast.Load)
|
206
230
|
and anode.id not in names
|
207
|
-
and anode.id not in
|
231
|
+
and anode.id not in namespace
|
208
232
|
):
|
209
233
|
for k, v in modules_in_test_scope:
|
210
234
|
if anode.id in v.__dict__:
|
@@ -236,8 +260,8 @@ def get_patch_for(
|
|
236
260
|
return None
|
237
261
|
|
238
262
|
if (
|
239
|
-
|
240
|
-
and "given" not in
|
263
|
+
namespace.get("hypothesis") is sys.modules["hypothesis"]
|
264
|
+
and "given" not in namespace # more reliably present than `example`
|
241
265
|
):
|
242
266
|
decorator_func = "hypothesis.example"
|
243
267
|
else:
|
@@ -257,7 +281,7 @@ def get_patch_for(
|
|
257
281
|
decorator=decorator_func,
|
258
282
|
width=88 - len(prefix), # to match Black's default formatting
|
259
283
|
).transform_module(node)
|
260
|
-
return (
|
284
|
+
return (before, indent(after.code, prefix=prefix))
|
261
285
|
|
262
286
|
|
263
287
|
def make_patch(
|
@@ -265,6 +289,7 @@ def make_patch(
|
|
265
289
|
*,
|
266
290
|
msg: str = "Hypothesis: add explicit examples",
|
267
291
|
when: Optional[datetime] = None,
|
292
|
+
author: str = f"Hypothesis {__version__} <no-reply@hypothesis.works>",
|
268
293
|
) -> str:
|
269
294
|
"""Create a patch for (fname, before, after) triples."""
|
270
295
|
assert triples, "attempted to create empty patch"
|
@@ -274,7 +299,7 @@ def make_patch(
|
|
274
299
|
for fname, before, after in triples:
|
275
300
|
by_fname.setdefault(Path(fname), []).append((before, after))
|
276
301
|
|
277
|
-
diffs = [HEADER.format(msg=msg, when=when)]
|
302
|
+
diffs = [HEADER.format(msg=msg, when=when, author=author)]
|
278
303
|
for fname, changes in sorted(by_fname.items()):
|
279
304
|
source_before = source_after = fname.read_text(encoding="utf-8")
|
280
305
|
for before, after in changes:
|
@@ -192,6 +192,10 @@ def _constants_from_source(source: Union[str, bytes], *, limit: bool) -> Constan
|
|
192
192
|
return visitor.constants
|
193
193
|
|
194
194
|
|
195
|
+
def _constants_file_str(constants: Constants) -> str:
|
196
|
+
return str(sorted(constants, key=lambda v: (str(type(v)), v)))
|
197
|
+
|
198
|
+
|
195
199
|
@lru_cache(4096)
|
196
200
|
def constants_from_module(module: ModuleType, *, limit: bool = True) -> Constants:
|
197
201
|
try:
|
@@ -236,7 +240,7 @@ def constants_from_module(module: ModuleType, *, limit: bool = True) -> Constant
|
|
236
240
|
# somewhat arbitrary sort order. The cache file doesn't *have* to be
|
237
241
|
# stable... but it is aesthetically pleasing, and means we could rely
|
238
242
|
# on it in the future!
|
239
|
-
+
|
243
|
+
+ _constants_file_str(constants),
|
240
244
|
encoding="utf-8",
|
241
245
|
)
|
242
246
|
except Exception: # pragma: no cover
|
hypothesis/version.py
CHANGED
@@ -14,10 +14,10 @@ hypothesis/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
14
14
|
hypothesis/reporting.py,sha256=f-jhl1JfAi5_tG8dsUd2qDjGcPdvxEzfF6hXmpTFQ1g,1761
|
15
15
|
hypothesis/stateful.py,sha256=vQ8wDO7YW-8nGlBGLfR9ariwmRCS9jxJy-Ky3swXjDE,42861
|
16
16
|
hypothesis/statistics.py,sha256=kZ5mc0fAg7gnSO6EmDo82fyz8DYhIiJ_mHe7srxOeQ0,5438
|
17
|
-
hypothesis/version.py,sha256=
|
17
|
+
hypothesis/version.py,sha256=2cgiH3RVZ2YHrP3mS9FXI4dZXTKhr9HPeF4V-9yoL_A,498
|
18
18
|
hypothesis/extra/__init__.py,sha256=gx4ENVDkrzBxy5Lv3Iyfs3tvMGdWMbiHfi95B7t61CY,415
|
19
19
|
hypothesis/extra/_array_helpers.py,sha256=PLmFckBfQpzQ4Q3dFJQqMmrbm7Qdvqxf1t9LHDCuSp0,27627
|
20
|
-
hypothesis/extra/_patching.py,sha256=
|
20
|
+
hypothesis/extra/_patching.py,sha256=A5s5EAf81itr--w4SAFyzuecSZm4eT397jM7BvbnQXU,12385
|
21
21
|
hypothesis/extra/array_api.py,sha256=bv_wisQS56wvwg-LiC26DxvzmPxcNLzlbzmltFWZ_Jo,42609
|
22
22
|
hypothesis/extra/cli.py,sha256=HOH_BGosyUvS4yNDsWF4Dfe672tEFGT4BBPBuZamm1s,12885
|
23
23
|
hypothesis/extra/codemods.py,sha256=i_iM5aSnrNjSZ_uNW40yShxXo7qaXuCrDHy8OznOa7o,11224
|
@@ -39,7 +39,7 @@ hypothesis/internal/cache.py,sha256=5GJ92S7HNjefuiOOSUchp3IYw1XxLVRmYoFHEoL7eVk,
|
|
39
39
|
hypothesis/internal/cathetus.py,sha256=q6t16mT2jzlJmBddhRlqC2wg_w7FggVDRAVkzs04W-U,2258
|
40
40
|
hypothesis/internal/charmap.py,sha256=dIsRCxa6r1r-rF_NUy04Z-afFa2b6fCFEjWTMYsAgXY,11781
|
41
41
|
hypothesis/internal/compat.py,sha256=CexhnEVndODX3E-iJmBzt_svqLmADF_6vWkd7lXLRQI,10970
|
42
|
-
hypothesis/internal/constants_ast.py,sha256=
|
42
|
+
hypothesis/internal/constants_ast.py,sha256=VcItL6O6LbNd-NpunBuonKE9rLNVVxNlOfTDY8Lqci0,10189
|
43
43
|
hypothesis/internal/coverage.py,sha256=u2ALnaYgwd2jSkZkA5aQYA1uMnk7gwaasMJbq_l3iIg,3380
|
44
44
|
hypothesis/internal/detection.py,sha256=v_zf0GYsnfJKQMNw78qYv61Dh-YaXXfgqKpVIOsBvfw,1228
|
45
45
|
hypothesis/internal/entropy.py,sha256=wgNeddIM0I3SD1yydz12Lsop6Di5vsle4e9u5fWAxIs,8014
|
@@ -105,9 +105,9 @@ hypothesis/utils/terminal.py,sha256=IxGYDGaE4R3b_vMfz5buWbN18XH5qVP4IxqAgNAU5as,
|
|
105
105
|
hypothesis/vendor/__init__.py,sha256=gx4ENVDkrzBxy5Lv3Iyfs3tvMGdWMbiHfi95B7t61CY,415
|
106
106
|
hypothesis/vendor/pretty.py,sha256=WEZC-UV-QQgCjUf2Iz1WWaWnbgT7Hc3s-GWEVxq-Qz0,36114
|
107
107
|
hypothesis/vendor/tlds-alpha-by-domain.txt,sha256=W9hYvpu2BMmNgE-SfPp8-GTzEVjw0HJUviqlvHwpZu8,9588
|
108
|
-
hypothesis-6.135.
|
109
|
-
hypothesis-6.135.
|
110
|
-
hypothesis-6.135.
|
111
|
-
hypothesis-6.135.
|
112
|
-
hypothesis-6.135.
|
113
|
-
hypothesis-6.135.
|
108
|
+
hypothesis-6.135.9.dist-info/licenses/LICENSE.txt,sha256=rIkDe6xjVQZE3OjPMsZ2Xl-rncGhzpS4n4qAXzQaZ1A,17141
|
109
|
+
hypothesis-6.135.9.dist-info/METADATA,sha256=Y5tNxfqmY2oL2NkcTrxP3ytDT-iZnoZT5kfz1XIUKa8,5637
|
110
|
+
hypothesis-6.135.9.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
111
|
+
hypothesis-6.135.9.dist-info/entry_points.txt,sha256=JDoUs9w1bYme7aG_eJ1cCtstRTWD71BzG8iRi-G2eHE,113
|
112
|
+
hypothesis-6.135.9.dist-info/top_level.txt,sha256=ReGreaueiJ4d1I2kEiig_CLeA0sD4QCQ4qk_8kH1oDc,81
|
113
|
+
hypothesis-6.135.9.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|