Skip to content

Commit

Permalink
Merge 2389bfa into 9f049b2
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Howitz committed Oct 10, 2018
2 parents 9f049b2 + 2389bfa commit c2bb167
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
3 changes: 2 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
4.2 (unreleased)
================

- Nothing changed yet.
- Fix regression introduced in 4.1.1 where to `_Smallest` objects are no longer
equal.


4.1.1 (2018-10-05)
Expand Down
3 changes: 2 additions & 1 deletion src/zope/sequencesort/ssort.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,6 @@ def __call__(self, o1, o2):
else:
req_len = n_fields + 1


# assert that o1 and o2 are tuples of apropriate length
if len(o1) != req_len:
raise ValueError("%s, %d" % (o1, req_len))
Expand All @@ -256,6 +255,8 @@ def __call__(self, o1, o2):
# if not multsort - i is 0, and the 0th element is the key
c1, c2 = o1[i], o2[i]
func, multiplier = self.sf_list[i][1:3]
if c1 is _Smallest and c2 is _Smallest:
return 0
if c1 is _Smallest:
return -1
elif c2 is _Smallest:
Expand Down
6 changes: 6 additions & 0 deletions src/zope/sequencesort/tests/test_ssort.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,12 @@ def test_multiple(self):
self.assertEqual(sb((['a', 'q'], None), (['a', 'r'], None)), 1)
self.assertEqual(sb((['b', 'p'], None), (['a', 'q'], None)), 1)

def test_smallest(self):
from zope.sequencesort.ssort import _Smallest
sb = self._makeOne(False, [self._makeField('bar')])
self.assertEqual(sb(('a', None), (_Smallest, None)), 1)
self.assertEqual(sb((_Smallest, None), ('a', None)), -1)
self.assertEqual(sb((_Smallest, None), (_Smallest, None)), 0)

WORDLIST = [
{"key": "aaa", "word": "AAA", "weight": 1},
Expand Down

0 comments on commit c2bb167

Please sign in to comment.