Skip to content

Commit 188d543

Browse files
committed
update future import test
Fixed test suite to not rely upon ancient "future division" statement to test the :paramref:`.Template.future_imports` feature. The test is replaced with one that tests only the rendering, not the ultimate effect. Also updates ancient documentation that also refers to this now defunct future statement Fixes: #408 Change-Id: I3e7d5bceb31fb141e2ea513d099be267dda1abe2
1 parent 798abe4 commit 188d543

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

doc/build/unreleased/408.rst

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.. change::
2+
:tags: bug, tests
3+
:tickets: 408
4+
5+
Fixed test suite to not rely upon ancient "future division" statement to
6+
test the :paramref:`.Template.future_imports` feature. The test is
7+
replaced with one that tests only the rendering, not the ultimate effect.

mako/template.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,7 @@ class Template:
119119
:param future_imports: String list of names to import from `__future__`.
120120
These will be concatenated into a comma-separated string and inserted
121121
into the beginning of the template, e.g. ``futures_imports=['FOO',
122-
'BAR']`` results in ``from __future__ import FOO, BAR``. If you're
123-
interested in using features like the new division operator, you must
124-
use future_imports to convey that to the renderer, as otherwise the
125-
import will not appear as the first executed statement in the generated
126-
code and will therefore not have the desired effect.
122+
'BAR']`` results in ``from __future__ import FOO, BAR``.
127123
128124
:param include_error_handler: An error handler that runs when this template
129125
is included within another one via the ``<%include>`` tag, and raises an

test/test_template.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1775,8 +1775,8 @@ def test_via_lookup(self):
17751775

17761776
class FuturesTest(TemplateTest):
17771777
def test_future_import(self):
1778-
t = Template("${ x / y }", future_imports=["division"])
1779-
assert result_lines(t.render(x=12, y=5)) == ["2.4"]
1778+
t = Template("foobar", future_imports=["annotations"])
1779+
assert t.code.startswith("from __future__ import annotations")
17801780

17811781

17821782
class EscapeTest(TemplateTest):

0 commit comments

Comments
 (0)