mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 13:22:48 +00:00
Don't overwrite builtin jinja2 filters with tests (#37881)
* Don't overwrite builtin jinja2 filters with tests. Fixes #37856 * Fix tests and other callers of _get_filters
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
from ansible.template import Templar, display
|
||||
from units.mock.loader import DictDataLoader
|
||||
from jinja2.filters import FILTERS
|
||||
from os.path import isabs
|
||||
|
||||
|
||||
def test_tests_as_filters_warning(mocker):
|
||||
@@ -7,7 +9,7 @@ def test_tests_as_filters_warning(mocker):
|
||||
"/path/to/my_file.txt": "foo\n",
|
||||
})
|
||||
templar = Templar(loader=fake_loader, variables={})
|
||||
filters = templar._get_filters()
|
||||
filters = templar._get_filters(templar.environment.filters)
|
||||
|
||||
mocker.patch.object(display, 'deprecated')
|
||||
|
||||
@@ -28,3 +30,6 @@ def test_tests_as_filters_warning(mocker):
|
||||
display.deprecated.reset_mock()
|
||||
filters['bool'](True)
|
||||
assert display.deprecated.call_count == 0
|
||||
|
||||
# Ensure custom test does not override builtin filter
|
||||
assert filters.get('abs') != isabs
|
||||
|
||||
Reference in New Issue
Block a user