]> git.ipfire.org Git - thirdparty/jinja.git/commitdiff
ensure deprecation warnings mention version
authorDavid Lord <davidism@gmail.com>
Fri, 10 Jan 2020 18:46:52 +0000 (10:46 -0800)
committerDavid Lord <davidism@gmail.com>
Fri, 10 Jan 2020 20:39:14 +0000 (12:39 -0800)
setup.cfg
src/jinja2/environment.py
src/jinja2/filters.py
src/jinja2/sandbox.py
tests/test_filters.py
tox.ini

index a9dfcbb01abdecf1333fb126f0e1a8f81ee1360c..efa15ca9d30df7cdad5ca02f7c601b4d7e6ac90d 100644 (file)
--- 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
index d3328311437fa90b27429ef4558058cf5eb53269..33a7b23a14d4cd1e7273e5c8a1f0f7f0dd30bf1e 100644 (file)
@@ -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
index 79394ad7d9ddf4c30c3b6d8bb56f45eb190e7317..456a6d41e7bfc637f3fae56509f89979b1ef76f8 100644 (file)
@@ -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
index bf4a0f6798370822d781c8a10cb34eea491eecbe..d806b63404fd53afcad17cd4d8897f02db3bccdf 100644 (file)
@@ -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
index ae10eb5e9623286616d846e62c656665cacac988..388e286f6b5ea8c7dfa69504a9afe768eeef3ab1 100644 (file)
@@ -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 60b987642d92219c2ab2b852e874c3a133a23844..0928efaf4ece0f658cd8924a64789327d1e170d6 100644 (file)
--- 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 =