Skip to content

Commit f0b8c22

Browse files
authored
Merge pull request #3371 from richardscholtens/fix_issue_#3370_hypothesis
2 parents a11ec6f + fe8913f commit f0b8c22

File tree

4 files changed

+12
-10
lines changed

4 files changed

+12
-10
lines changed

AUTHORS.rst

+4
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ their individual contributions.
3232
* `Chase Garner <https://www.github.com/chasegarner>`_ ([email protected])
3333
* `Cheuk Ting Ho <https://github.com/Cheukting>`_
3434
* `Chris Down <https://chrisdown.name>`_
35+
* `Chris van Dronkelaar <https://github.com/Chrisvandr>`_
3536
* `Christopher Martin <https://www.github.com/chris-martin>`_ ([email protected])
3637
* `Claudio Jolowicz <https://github.com/cjolowicz>`_
3738
* `Conrad Ho <https://www.github.com/conradho>`_ ([email protected])
@@ -126,6 +127,7 @@ their individual contributions.
126127
* `Pierre-Jean Campigotto <https://github.com/PJCampi>`_
127128
* `Przemek Konopko <https://github.com/soutys>`_
128129
* `Richard Boulton <https://www.github.com/rboulton>`_ ([email protected])
130+
* `Richard Scholtens <https://github.com/richardscholtens>`_ ([email protected])
129131
* `Robert Howlett <https://github.com/jebob>`_
130132
* `Robert Knight <https://github.com/robertknight>`_ ([email protected])
131133
* `Rónán Carrigan <https://www.github.com/rcarriga>`_ ([email protected])
@@ -138,6 +140,7 @@ their individual contributions.
138140
* `Sangarshanan <https://www.github.com/sangarshanan>`_ ([email protected])
139141
* `Sanyam Khurana <https://github.com/CuriousLearner>`_
140142
* `Saul Shanabrook <https://www.github.com/saulshanabrook>`_ ([email protected])
143+
* `Sebastiaan Zeeff <https://github.com/SebastiaanZ>`_ ([email protected])
141144
* `Shlok Gandhi <https://github.com/shlok57>`_ ([email protected])
142145
* `Sogata Ray <https://github.com/rayardinanda>`_ ([email protected])
143146
* `Stuart Cook <https://www.github.com/Zalathar>`_
@@ -155,6 +158,7 @@ their individual contributions.
155158
* `Tyler Nickerson <https://www.github.com/nmbrgts>`_
156159
* `Vidya Rani <https://www.github.com/vidyarani-dg>`_ ([email protected])
157160
* `Vincent Michel <https://www.github.com/vxgmichel>`_ ([email protected])
161+
* `Viorel Pluta <https://github.com/viopl>`_ ([email protected])
158162
* `Vytautas Strimaitis <https://www.github.com/vstrimaitis>`_
159163
* `Will Hall <https://www.github.com/wrhall>`_ ([email protected])
160164
* `Will Thompson <https://www.github.com/wjt>`_ ([email protected])

hypothesis-python/RELEASE.rst

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
RELEASE_TYPE: patch
2+
3+
Our pretty-printer no longer sorts dictionary keys, since iteration order is
4+
stable in Python 3.7+ and this can affect reproducing examples (:issue:`3370`).
5+
This PR was kindly supported by `Ordina Pythoneers
6+
<https://www.ordina.nl/vakgebieden/python/>`__.

hypothesis-python/src/hypothesis/vendor/pretty.py

+1-10
Original file line numberDiff line numberDiff line change
@@ -603,16 +603,7 @@ def inner(obj, p, cycle):
603603
if cycle:
604604
return p.text("{...}")
605605
p.begin_group(1, start)
606-
keys = obj.keys()
607-
# if dict isn't large enough to be truncated, sort keys before
608-
# displaying
609-
if not (p.max_seq_length and len(obj) >= p.max_seq_length):
610-
try:
611-
keys = sorted(keys)
612-
except Exception:
613-
# Sometimes the keys don't sort.
614-
pass
615-
for idx, key in p._enumerate(keys):
606+
for idx, key in p._enumerate(obj):
616607
if idx:
617608
p.text(",")
618609
p.breakable()

hypothesis-python/tests/cover/test_pretty.py

+1
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ def test_list():
134134
def test_dict():
135135
assert pretty.pretty({}) == "{}"
136136
assert pretty.pretty({1: 1}) == "{1: 1}"
137+
assert pretty.pretty({1: 1, 0: 0}) == "{1: 1, 0: 0}"
137138

138139

139140
def test_tuple():

0 commit comments

Comments
 (0)