Skip to content

Commit

Permalink
fix random test for py2
Browse files Browse the repository at this point in the history
add changelog
  • Loading branch information
davidism committed Jul 5, 2017
1 parent c8636fe commit 2e15e52
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ Version 2.10
- Added a `trimmed` modifier to `{% trans %}` to strip linebreaks and
surrounding whitespace. Also added a new policy to enable this for all
`trans` blocks.
- The ``random`` filter is no longer incorrectly constant folded and will
produce a new random choice each time the template is rendered. (`#478`_)

.. _#478: https://github.com/pallets/jinja/pull/478

Version 2.9.6
-------------
Expand Down
4 changes: 2 additions & 2 deletions tests/test_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,12 @@ def test_random(self, env, request):
state = random.getstate()
request.addfinalizer(lambda: random.setstate(state))
# generate the random values from a known seed
random.seed('jinja', version=2)
random.seed('jinja')
expected = [random.choice('1234567890') for _ in range(10)]

# check that the random sequence is generated again by a template
# ensures that filter result is not constant folded
random.seed('jinja', version=2)
random.seed('jinja')
t = env.from_string('{{ "1234567890"|random }}')

for value in expected:
Expand Down

0 comments on commit 2e15e52

Please sign in to comment.