test/: PEP8 compliancy (#24803)

* test/: PEP8 compliancy

- Make PEP8 compliant

* Python3 chokes on casting int to bytes (#24952)

But if we tell the formatter that the var is a number, it works
This commit is contained in:
Dag Wieers 2017-05-30 19:05:19 +02:00 committed by John R Barker
parent 31c59ad5f9
commit 4efec414e7
110 changed files with 1702 additions and 1547 deletions

View file

@ -27,6 +27,7 @@ from ansible.template import _escape_backslashes, _count_newlines_from_end
# These are internal utility functions only needed for templating. They're
# algorithmic so good candidates for unittesting by themselves
class TestBackslashEscape(unittest.TestCase):
test_data = (
@ -36,7 +37,7 @@ class TestBackslashEscape(unittest.TestCase):
intermediate=u"{{ 'test2 %s' | format('\\\\1') }}",
expectation=u"test2 \\1",
args=dict()
),
),
# Test backslashes inside the jinja2 var itself are double
# escaped
dict(
@ -44,7 +45,7 @@ class TestBackslashEscape(unittest.TestCase):
intermediate=u"Test 2\\3: {{ '\\\\1 %s' | format('\\\\2') }}",
expectation=u"Test 2\\3: \\1 \\2",
args=dict()
),
),
# Test backslashes outside of the jinja2 var are not double
# escaped
dict(
@ -52,14 +53,14 @@ class TestBackslashEscape(unittest.TestCase):
intermediate=u"Test 2\\3: {{ 'test2 %s' | format('\\\\1') }}; \\done",
expectation=u"Test 2\\3: test2 \\1; \\done",
args=dict()
),
),
# Test backslashes in a variable sent to a filter are handled
dict(
template=u"{{ 'test2 %s' | format(var1) }}",
intermediate=u"{{ 'test2 %s' | format(var1) }}",
expectation=u"test2 \\1",
args=dict(var1=u'\\1')
),
),
# Test backslashes in a variable expanded by jinja2 are double
# escaped
dict(
@ -67,8 +68,9 @@ class TestBackslashEscape(unittest.TestCase):
intermediate=u"Test 2\\3: {{ var1 | format('\\\\2') }}",
expectation=u"Test 2\\3: \\1 \\2",
args=dict(var1=u'\\1 %s')
),
)
),
)
def setUp(self):
self.env = jinja2.Environment()
@ -84,6 +86,7 @@ class TestBackslashEscape(unittest.TestCase):
args = test['args']
self.assertEquals(template.render(**args), test['expectation'])
class TestCountNewlines(unittest.TestCase):
def setUp(self):