diff options
Diffstat (limited to 'test/units/template/test_templar.py')
-rw-r--r-- | test/units/template/test_templar.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/test/units/template/test_templar.py b/test/units/template/test_templar.py index 02840e16..6747f768 100644 --- a/test/units/template/test_templar.py +++ b/test/units/template/test_templar.py @@ -22,10 +22,11 @@ __metaclass__ = type from jinja2.runtime import Context from units.compat import unittest +from unittest.mock import patch from ansible import constants as C from ansible.errors import AnsibleError, AnsibleUndefinedVariable -from ansible.plugins.loader import init_plugin_loader +from ansible.module_utils.six import string_types from ansible.template import Templar, AnsibleContext, AnsibleEnvironment, AnsibleUndefined from ansible.utils.unsafe_proxy import AnsibleUnsafe, wrap_var from units.mock.loader import DictDataLoader @@ -33,7 +34,6 @@ from units.mock.loader import DictDataLoader class BaseTemplar(object): def setUp(self): - init_plugin_loader() self.test_vars = dict( foo="bar", bam="{{foo}}", @@ -62,6 +62,14 @@ class BaseTemplar(object): return self._ansible_context._is_unsafe(obj) +# class used for testing arbitrary objects passed to template +class SomeClass(object): + foo = 'bar' + + def __init__(self): + self.blip = 'blip' + + class SomeUnsafeClass(AnsibleUnsafe): def __init__(self): super(SomeUnsafeClass, self).__init__() @@ -258,6 +266,8 @@ class TestTemplarMisc(BaseTemplar, unittest.TestCase): templar.available_variables = "foo=bam" except AssertionError: pass + except Exception as e: + self.fail(e) def test_templar_escape_backslashes(self): # Rule of thumb: If escape backslashes is True you should end up with |