Merge pull request #35179 from rallytime/py3-unit-template-tests

PY3: Fixup jinja template unit tests
This commit is contained in:
Mike Place 2016-08-07 06:48:51 +09:00 committed by GitHub
commit 6e7f907d36

View File

@ -16,6 +16,8 @@ from salttesting.helpers import ensure_in_syspath
ensure_in_syspath('../../')
# Import salt libs
import salt.config
import salt.ext.six as six
import salt.loader
import salt.utils
from salt.exceptions import SaltRenderError
@ -341,7 +343,9 @@ class TestGetTemplate(TestCase):
fn = os.path.join(TEMPLATES_DIR, 'files', 'test', 'non_ascii')
out = JINJA(fn, opts=self.local_opts, saltenv='test')
with salt.utils.fopen(out['data']) as fp:
result = fp.read().decode('utf-8')
result = fp.read()
if six.PY2:
result = result.decode('utf-8')
self.assertEqual(u'Assunção\n', result)
def test_get_context_has_enough_context(self):
@ -385,6 +389,7 @@ class TestGetTemplate(TestCase):
dict(opts=self.local_opts, saltenv='test')
)
@skipIf(six.PY3, 'Not applicable to Python 3: skipping.')
def test_render_with_unicode_syntax_error(self):
encoding = builtins.__salt_system_encoding__
builtins.__salt_system_encoding__ = 'utf-8'