summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Lord <davidism@gmail.com>2020-01-10 10:46:52 -0800
committerDavid Lord <davidism@gmail.com>2020-01-10 12:39:14 -0800
commit963b5d3c3f426fa36160caef8a1f437e59036bdf (patch)
tree44a8d969e297055223afe109f2a96b67475f6c8e
parentbb6216ea305a06d0157f0c0d0fb8be7bb625c523 (diff)
downloadjinja2-963b5d3c3f426fa36160caef8a1f437e59036bdf.tar.gz
ensure deprecation warnings mention version
-rw-r--r--setup.cfg3
-rw-r--r--src/jinja2/environment.py9
-rw-r--r--src/jinja2/filters.py11
-rw-r--r--src/jinja2/sandbox.py3
-rw-r--r--tests/test_filters.py4
-rw-r--r--tox.ini2
6 files changed, 19 insertions, 13 deletions
diff --git a/setup.cfg b/setup.cfg
index a9dfcbb..efa15ca 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -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"),
(
diff --git a/tox.ini b/tox.ini
index 60b9876..0928efa 100644
--- a/tox.ini
+++ b/tox.ini
@@ -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 =