def test_line_separators_preserved(source_with_newline, newline): options = OPTIONS[0] options = attr.evolve(options, write_back=core.WriteBackMode.INPLACE) source = source_with_newline(newline) core.reformat_single_file(source, options=options) with open(source, "rb") as buf: _newline = core.decode_bytes(buf.read())[2] assert _newline == newline
def test_line_separators_changed(source_with_newline, newline_mode, newline): options = OPTIONS[0] options = attr.evolve(options, write_back=core.WriteBackMode.INPLACE, newline=newline_mode) source = source_with_newline(newline) core.reformat_single_file(source, options=options) with open(source, "rb") as buf: _newline = core.decode_stream(buf)[2] assert _newline == core.NEWLINE_FROM_OPTION[newline_mode]