diff options
-rw-r--r-- | setup.cfg | 3 | ||||
-rw-r--r-- | src/jinja2/environment.py | 9 | ||||
-rw-r--r-- | src/jinja2/filters.py | 11 | ||||
-rw-r--r-- | src/jinja2/sandbox.py | 3 | ||||
-rw-r--r-- | tests/test_filters.py | 4 | ||||
-rw-r--r-- | tox.ini | 2 |
6 files changed, 19 insertions, 13 deletions
@@ -6,6 +6,9 @@ universal = true [tool:pytest] testpaths = tests +filterwarnings = + error + ignore:the sets module:DeprecationWarning:jinja2.sandbox [coverage:run] branch = True diff --git a/src/jinja2/environment.py b/src/jinja2/environment.py index d332831..33a7b23 100644 --- a/src/jinja2/environment.py +++ b/src/jinja2/environment.py @@ -727,9 +727,14 @@ class Environment(object): if py_compile: if not PY2 or PYPY: - from warnings import warn + import warnings - warn(Warning("py_compile has no effect on pypy or Python 3")) + warnings.warn( + "'py_compile=True' has no effect on PyPy or Python" + " 3 and will be removed in version 3.0", + DeprecationWarning, + stacklevel=2, + ) py_compile = False else: import imp diff --git a/src/jinja2/filters.py b/src/jinja2/filters.py index 79394ad..456a6d4 100644 --- a/src/jinja2/filters.py +++ b/src/jinja2/filters.py @@ -16,6 +16,10 @@ from collections import namedtuple from itertools import chain from itertools import groupby +from markupsafe import escape +from markupsafe import Markup +from markupsafe import soft_unicode + from ._compat import abc from ._compat import imap from ._compat import iteritems @@ -23,11 +27,8 @@ from ._compat import string_types from ._compat import text_type from .exceptions import FilterArgumentError from .runtime import Undefined -from .utils import escape from .utils import htmlsafe_json_dumps -from .utils import Markup from .utils import pformat -from .utils import soft_unicode from .utils import unicode_urlencode from .utils import urlize @@ -639,7 +640,9 @@ def do_indent(s, width=4, first=False, blank=False, indentfirst=None): """ if indentfirst is not None: warnings.warn( - DeprecationWarning('The "indentfirst" argument is renamed to "first".'), + "The 'indentfirst' argument is renamed to 'first' and will" + " be removed in version 3.0.", + DeprecationWarning, stacklevel=2, ) first = indentfirst diff --git a/src/jinja2/sandbox.py b/src/jinja2/sandbox.py index bf4a0f6..d806b63 100644 --- a/src/jinja2/sandbox.py +++ b/src/jinja2/sandbox.py @@ -59,14 +59,13 @@ UNSAFE_ASYNC_GENERATOR_ATTRIBUTES = {"ag_code", "ag_frame"} # make sure we don't warn in python 2.6 about stuff we don't care about warnings.filterwarnings( - "ignore", "the sets module", DeprecationWarning, module="jinja2.sandbox" + "ignore", "the sets module", DeprecationWarning, module=__name__ ) _mutable_set_types = (set,) _mutable_mapping_types = (dict,) _mutable_sequence_types = (list,) - # on python 2.x we can register the user collection types try: from UserDict import UserDict, DictMixin diff --git a/tests/test_filters.py b/tests/test_filters.py index ae10eb5..388e286 100644 --- a/tests/test_filters.py +++ b/tests/test_filters.py @@ -196,10 +196,6 @@ class TestFilter(object): """ self._test_indent_multiline_template(env, markup=True) - def test_indentfirst_deprecated(self, env): - with pytest.warns(DeprecationWarning): - env.from_string('{{ "jinja"|indent(indentfirst=true) }}').render() - @pytest.mark.parametrize( ("value", "expect"), ( @@ -9,7 +9,7 @@ skip_missing_interpreters = true deps = coverage pytest -commands = coverage run -p -m pytest --tb=short -Werror --basetemp={envtmpdir} {posargs} +commands = coverage run -p -m pytest --tb=short --basetemp={envtmpdir} {posargs} [testenv:docs-html] deps = |