Skip to content

Commit d8bb4a2

Browse files
committed
Register ignore_template_errors marker
Fixes #609. Closes #610.
1 parent 321bb6b commit d8bb4a2

File tree

3 files changed

+21
-6
lines changed

3 files changed

+21
-6
lines changed

docs/changelog.rst

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
Changelog
22
=========
33

4-
3.3.1 (2018-06-21)
4+
unreleased
5+
------------------
6+
7+
Bug fixes
8+
^^^^^^^^^
9+
10+
* Fixed registration of :py:func:`~pytest.mark.ignore_template_errors` marker,
11+
which is required with ``pytest --strict`` (#609).
12+
13+
3.3.2 (2018-06-21)
514
------------------
615

716
Bug fixes

docs/helpers.rst

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,12 @@ when trying to access the database.
8282

8383
.. py:function:: pytest.mark.ignore_template_errors
8484
85-
If you run pytest using the ``--fail-on-template-vars`` option,
86-
tests will fail should your templates contain any invalid variables.
87-
This marker will disable this feature by setting ``settings.TEMPLATE_STRING_IF_INVALID=None``
88-
or the ``string_if_invalid`` template option
85+
Ignore errors when using the ``--fail-on-template-vars`` option, i.e.
86+
do not cause tests to fail if your templates contain invalid variables.
87+
88+
This marker sets the ``string_if_invalid`` template option, or
89+
the older ``settings.TEMPLATE_STRING_IF_INVALID=None`` (Django up to 1.10).
90+
See :ref:`django:invalid-template-variables`.
8991

9092
Example usage::
9193

pytest_django/plugin.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,10 @@ def pytest_load_initial_conftests(early_config, parser, args):
183183
'the `urls` attribute of Django `TestCase` objects. *modstr* is '
184184
'a string specifying the module of a URL config, e.g. '
185185
'"my_app.test_urls".')
186+
early_config.addinivalue_line(
187+
'markers',
188+
'ignore_template_errors(): ignore errors from invalid template '
189+
'variables (if --fail-on-template-vars is used).')
186190

187191
options = parser.parse_known_args(args)
188192

@@ -500,7 +504,7 @@ def _fail_for_invalid_template_variable(request):
500504
It does not raise an exception, but fails, as the stack trace doesn't
501505
offer any helpful information to debug.
502506
This behavior can be switched off using the marker:
503-
``ignore_template_errors``
507+
``pytest.mark.ignore_template_errors``
504508
"""
505509
class InvalidVarException(object):
506510
"""Custom handler for invalid strings in templates."""

0 commit comments

Comments
 (0)