Skip to content

Commit

Permalink
Add test and change log entry.
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Howitz committed Apr 12, 2018
1 parent 2bfe0df commit 5b43358
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGES.rst
Expand Up @@ -9,6 +9,8 @@ Changelog

- No longer use icons which got deleted in Zope 4.

- Fix sorting in <dtml-in> for duplicate entries in Python 3.


3.0b2 (2017-11-03)
------------------
Expand Down
34 changes: 34 additions & 0 deletions src/DocumentTemplate/tests/test_DT_In.py
@@ -0,0 +1,34 @@
import unittest


class DummySection(object):
blocks = ['dummy']


class TestIn(unittest.TestCase):
"""Testing ..DT_in.InClass."""

def _getTargetClass(self):
from DocumentTemplate.DT_In import InClass
return InClass

def _makeOne(self, *args):
blocks = [('in', ' '.join(args), DummySection())]
return self._getTargetClass()(blocks)

def test_sort_sequence(self):
"""It does not break on duplicate sort keys at a list of dicts."""
stmt = self._makeOne('seq', 'mapping', 'sort=key')
seq = [
{'key': 'c', 'data': '3'},
{'key': 'a', 'data': '1'},
{'key': 'b', 'data': '2'},
{'key': 'a', 'data': '2'},
]
result = stmt.sort_sequence(seq, 'key')
self.assertEqual([
{'key': 'a', 'data': '1'},
{'key': 'a', 'data': '2'},
{'key': 'b', 'data': '2'},
{'key': 'c', 'data': '3'},
], result)

0 comments on commit 5b43358

Please sign in to comment.