Use os.linesep.join instead of textwrap.dedent

This commit is contained in:
twangboy 2018-08-21 12:37:17 -06:00 committed by Daniel A. Wozniak
parent 5ba7f60f03
commit d3358423ae
No known key found for this signature in database
GPG key ID: 166B9D2C06C82D61

View file

@ -5,7 +5,7 @@ Tests for the file state
'''
# Import python libs
from __future__ import absolute_import
from __future__ import absolute_import, unicode_literals
import errno
import glob
import logging
@ -2647,57 +2647,57 @@ class FileTest(ModuleCase, SaltReturnAssertsMixin):
class BlockreplaceTest(ModuleCase, SaltReturnAssertsMixin):
marker_start = '# start'
marker_end = '# end'
content = textwrap.dedent('''\
Line 1 of block
Line 2 of block
''')
without_block = textwrap.dedent('''\
Hello world!
# comment here
''')
with_non_matching_block = textwrap.dedent('''\
Hello world!
# start
No match here
# end
# comment here
''')
with_non_matching_block_and_marker_end_not_after_newline = textwrap.dedent('''\
Hello world!
# start
No match here# end
# comment here
''')
with_matching_block = textwrap.dedent('''\
Hello world!
# start
Line 1 of block
Line 2 of block
# end
# comment here
''')
with_matching_block_and_extra_newline = textwrap.dedent('''\
Hello world!
# start
Line 1 of block
Line 2 of block
# end
# comment here
''')
with_matching_block_and_marker_end_not_after_newline = textwrap.dedent('''\
Hello world!
# start
Line 1 of block
Line 2 of block# end
# comment here
''')
content = os.linesep.join([
'Line 1 of block',
'Line 2 of block',
''])
without_block = os.linesep.join([
'Hello world!',
'',
'# comment here',
''])
with_non_matching_block = os.linesep.join([
'Hello world!',
'',
'# start',
'No match here',
'# end',
'# comment here',
''])
with_non_matching_block_and_marker_end_not_after_newline = os.linesep.join([
'Hello world!',
'',
'# start',
'No match here# end',
'# comment here',
''])
with_matching_block = os.linesep.join([
'Hello world!',
'',
'# start',
'Line 1 of block',
'Line 2 of block',
'# end',
'# comment here',
''])
with_matching_block_and_extra_newline = os.linesep.join([
'Hello world!',
'',
'# start',
'Line 1 of block',
'Line 2 of block',
'',
'# end',
'# comment here',
''])
with_matching_block_and_marker_end_not_after_newline = os.linesep.join([
'Hello world!',
'',
'# start',
'Line 1 of block',
'Line 2 of block# end',
'# comment here',
''])
content_explicit_posix_newlines = ('Line 1 of block\n'
'Line 2 of block\n')
content_explicit_windows_newlines = ('Line 1 of block\r\n'