mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-06-03 14:59:09 -07:00
Revert templating enhancements from 73dbab70
e6c28658
d409352c
9858b1f2
4587528b
9b1fe455
214b0b05
8d3db803
7f9504d1
5031104c
35cb9dc2
2bd8cb57
1e85c754
This commit is contained in:
parent
e0fbaea566
commit
d154bf8781
11 changed files with 1244 additions and 1397 deletions
|
@ -9,7 +9,6 @@ from nose.plugins.skip import SkipTest
|
|||
|
||||
import ansible.utils
|
||||
import ansible.utils.template as template2
|
||||
import ansible.constants as C
|
||||
|
||||
class TestUtils(unittest.TestCase):
|
||||
|
||||
|
@ -17,10 +16,6 @@ class TestUtils(unittest.TestCase):
|
|||
### varReplace function tests
|
||||
|
||||
def test_varReplace_var_complex_var(self):
|
||||
|
||||
old_setting = C.DEFAULT_LEGACY_PLAYBOOK_VARIABLES
|
||||
C.DEFAULT_LEGACY_PLAYBOOK_VARIABLES = True
|
||||
|
||||
vars = {
|
||||
'x': '$y',
|
||||
'y': {
|
||||
|
@ -31,8 +26,6 @@ class TestUtils(unittest.TestCase):
|
|||
res = template2.template(None, template, vars)
|
||||
assert res == 'result'
|
||||
|
||||
C.DEFAULT_LEGACY_PLAYBOOK_VARIABLES = old_setting
|
||||
|
||||
#####################################
|
||||
### template_ds function tests
|
||||
|
||||
|
@ -60,9 +53,6 @@ class TestUtils(unittest.TestCase):
|
|||
],
|
||||
}
|
||||
|
||||
old_setting = C.DEFAULT_LEGACY_PLAYBOOK_VARIABLES
|
||||
C.DEFAULT_LEGACY_PLAYBOOK_VARIABLES = True
|
||||
|
||||
template = '${data.var}'
|
||||
res = template2.template(None, template, vars)
|
||||
assert sorted(res) == sorted(vars['data']['var'])
|
||||
|
@ -79,8 +69,6 @@ class TestUtils(unittest.TestCase):
|
|||
res = template2.template(None, template, vars)
|
||||
assert res == template
|
||||
|
||||
C.DEFAULT_LEGACY_PLAYBOOK_VARIABLES = old_setting
|
||||
|
||||
#####################################
|
||||
### Template function tests
|
||||
|
||||
|
@ -93,6 +81,15 @@ class TestUtils(unittest.TestCase):
|
|||
|
||||
assert res == 'hello world'
|
||||
|
||||
def test_template_whitespace(self):
|
||||
vars = {
|
||||
'who': 'world',
|
||||
}
|
||||
|
||||
res = template2.template_from_file("test", "template-whitespace", vars)
|
||||
|
||||
assert res == 'hello world\n'
|
||||
|
||||
def test_template_unicode(self):
|
||||
vars = {
|
||||
'who': u'wórld',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue