Add unit test for mixed_line_ending

This commit is contained in:
Morgan Courbet 2017-07-03 19:57:43 +02:00
parent f477582ae6
commit b1294b8614
No known key found for this signature in database
GPG key ID: 467299D324A21B24
2 changed files with 36 additions and 1 deletions

View file

@ -74,7 +74,8 @@ def mixed_line_ending(argv=None):
if fix_option == MixedLineEndingOption.NO:
logging.info('No conversion asked')
pass
return 0
elif fix_option == MixedLineEndingOption.AUTO:
for filename in options['filenames']:
detect_result = _detect_line_ending(filename)
@ -90,12 +91,18 @@ def mixed_line_ending(argv=None):
le_enum.str_print, le_enum.str_print)
_convert_line_ending(filename, le_enum.string)
return 1
elif detect_result == MixedLineDetection.NOT_MIXED:
logging.info('The file %s has no mixed line ending', filename)
return 0
elif detect_result == MixedLineDetection.UNKNOWN:
logging.info('Could not define most frequent line ending in '
'file %s. File skiped.', filename)
return 0
# when a line ending character is forced with --fix option
else:
line_ending_enum = fix_option.line_ending_enum
@ -105,6 +112,8 @@ def mixed_line_ending(argv=None):
for filename in options['filenames']:
_convert_line_ending(filename, line_ending_enum.string)
return 1
return 0