Skip to content

Commit 0113a77

Browse files
authored
Merge pull request #4533 from Liam-DeVoe/next2
Preserve patch examples order
2 parents f09c331 + 2eec6ee commit 0113a77

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

hypothesis-python/RELEASE.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
RELEASE_TYPE: patch
2+
3+
Patch files written by hypothesis now use a deterministic ordering when multiple |@example| decorators are present.

hypothesis-python/src/hypothesis/extra/_patching.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,14 @@ def _get_patch_for(
209209
# The printed examples might include object reprs which are invalid syntax,
210210
# so we parse here and skip over those. If _none_ are valid, there's no patch.
211211
call_nodes: list[tuple[cst.Call, str]] = []
212-
for ex, via in set(examples):
212+
213+
# we want to preserve order, but remove duplicates.
214+
seen_examples = set()
215+
for ex, via in examples:
216+
if (ex, via) in seen_examples:
217+
continue
218+
seen_examples.add((ex, via))
219+
213220
with suppress(Exception):
214221
node: Any = cst.parse_module(ex)
215222
the_call = node.body[0].body[0].value

0 commit comments

Comments
 (0)