Skip to content
Myr

fix random test for py2

Before adoption: this commit came in with the history the project adopted, so no landing records it.

add changelog

authored by David Lord · committed by David Lord · parent c8636fe · Browse files · 2 files+6 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+6 added−2 removed

  • tests:+2 added−2 removed
  • other:+4 added−0 removed

2 files+6 added−2 removed

modified:tests/test_filters.py+2 added-2 removed
186 unmodified lines
187 # restore the random state when the test ends188 state = random.getstate()189 request.addfinalizer(lambda: random.setstate(state))190 # generate the random values from a known seed191 random.seed('jinja', version=2)191 random.seed('jinja')192 expected = [random.choice('1234567890') for _ in range(10)]193194 # check that the random sequence is generated again by a template195 # ensures that filter result is not constant folded196 random.seed('jinja', version=2)196 random.seed('jinja')197 t = env.from_string('{{ "1234567890"|random }}')198199 for value in expected:200 assert t.render() == value
402 unmodified lines
modified:CHANGES+4 added
20 unmodified lines
21 across scopes, e.g. from a loop body to code that comes after the loop.22- Added a `trimmed` modifier to `{% trans %}` to strip linebreaks and23 surrounding whitespace. Also added a new policy to enable this for all24 `trans` blocks.25- The ``random`` filter is no longer incorrectly constant folded and will26 produce a new random choice each time the template is rendered. (`#478`_)2728.. _#478: https://github.com/pallets/jinja/pull/4782930Version 2.9.631-------------32(bugfix release, released on April 3rd 2017)33
503 unmodified lines