Skip to content

Commit

Permalink
ISSUE-1902 Fix Template::is_up_to_date contract
Browse files Browse the repository at this point in the history
ISSUE-1902 CHANGES.rst

ISSUE-1902 Add PR info to CHANGES.rst

ISSUE-1902 Test
  • Loading branch information
rwielk committed Oct 25, 2023
1 parent d594969 commit 0bcbad2
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Version 3.2.0

Unreleased

- Fix Template's type hint contract :pr: `1903`
- Use modern packaging metadata with ``pyproject.toml`` instead of ``setup.cfg``.
:pr:`1793`
- Use ``flit_core`` instead of ``setuptools`` as build backend.
Expand Down
2 changes: 1 addition & 1 deletion src/jinja2/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -1493,7 +1493,7 @@ def is_up_to_date(self) -> bool:
"""If this variable is `False` there is a newer version available."""
if self._uptodate is None:
return True
return self._uptodate()
return self._uptodate() if callable(self._uptodate) else self._uptodate

@property
def debug_info(self) -> t.List[t.Tuple[int, int]]:
Expand Down
22 changes: 22 additions & 0 deletions tests/test_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,28 @@


class TestCorner:
def test_uptodate_loader(self, env):
class UpToDateDictLoader(DictLoader):
def get_source(self, environment: "Environment", template: str):
contents, path, uptodate = super().get_source(environment, template)
return contents, path, True

env = Environment(
loader=UpToDateDictLoader(
{
"a.html": """
{%- set foo = 'bar' -%}
{% include 'x.html' -%}{% include 'x.html' -%}
""",
"x.html": """{{ foo }}|{{ test }}""",
}
)
)

a = env.get_template("a.html")

assert a.render(test="x").strip() == "bar|xbar|x"

def test_assigned_scoping(self, env):
t = env.from_string(
"""
Expand Down

0 comments on commit 0bcbad2

Please sign in to comment.