Fix test_rendering_includes for Windows

This commit is contained in:
twangboy 2017-02-24 15:28:03 -07:00
parent 89635b4467
commit f43445d3de

View File

@ -23,7 +23,6 @@ class PyDSLRendererIncludeTestCase(integration.ModuleCase):
inability to load custom modules inside the pydsl renderers. This inability to load custom modules inside the pydsl renderers. This
is a FIXME. is a FIXME.
''' '''
try:
self.run_function('state.sls', ['pydsl.aaa']) self.run_function('state.sls', ['pydsl.aaa'])
expected = textwrap.dedent('''\ expected = textwrap.dedent('''\
@ -38,12 +37,27 @@ class PyDSLRendererIncludeTestCase(integration.ModuleCase):
hello blue 3 hello blue 3
''') ''')
with salt.utils.fopen('/tmp/output', 'r') as f: # Windows adds `linefeed` in addition to `newline`. There's also an
self.assertEqual(sorted(f.read()), sorted(expected)) # unexplainable space before the `linefeed`...
if salt.utils.is_windows():
expected = 'X1 \r\n' \
'X2 \r\n' \
'X3 \r\n' \
'Y1 extended \r\n' \
'Y2 extended \r\n' \
'Y3 \r\n' \
'hello red 1 \r\n' \
'hello green 2 \r\n' \
'hello blue 3 \r\n'
with salt.utils.fopen('/tmp/output', 'r') as f:
ret = f.read()
finally:
os.remove('/tmp/output') os.remove('/tmp/output')
self.assertEqual(sorted(ret), sorted(expected))
if __name__ == '__main__': if __name__ == '__main__':
from integration import run_tests from integration import run_tests
tests = [PyDSLRendererIncludeTestCase] tests = [PyDSLRendererIncludeTestCase]