def test_three_newline_characters(self): """Test three empty lines. First and last entries should be empty.""" body = "\n\n\n" expected = ["", "\n", "", "\n", "", "\n", ""] actual = helpers.split_lines(body) assert actual == expected body = "\n\r\n\n" expected = ["", "\n", "", "\r\n", "", "\n", ""] actual = helpers.split_lines(body) assert actual == expected body = "\r\n\r\n\r\n" expected = ["", "\r\n", "", "\r\n", "", "\r\n", ""] actual = helpers.split_lines(body) assert actual == expected
def test_form_feed_character_mixed_in(self): """Test handling of form feed character.""" body = "line1\nline2\fstill on line2\nline3\n" expected = [ "line1", "\n", "line2\fstill on line2", "\n", "line3", "\n", "" ] actual = helpers.split_lines(body) assert actual == expected
def test_one_line_followed_by_newline_characters(self): """Test one line followed by newlines. Last entry should be empty.""" body = "line1\n\n\n" expected = ["line1", "\n", "", "\n", "", "\n", ""] actual = helpers.split_lines(body) assert actual == expected
def test_three_lines_mix_linesep_eof_linesep(self): """Test a mix of line separators with EOF CRLF. Last entry should be empty.""" body = "line1\r\nline2\nline3\r\n" expected = ["line1", "\r\n", "line2", "\n", "line3", "\r\n", ""] actual = helpers.split_lines(body) assert actual == expected
def test_three_lines_mix_linesep_no_eof_linesep(self): """Test a mix of dos and posix line separators. Result should include both.""" body = "line1\r\nline2\nline3" expected = ["line1", "\r\n", "line2", "\n", "line3"] actual = helpers.split_lines(body) assert actual == expected
def test_two_lines_eof_linesep_dos(self): """Test two lines with CRLF line terminators. Last entry should be empty.""" body = "line1\r\nline2\r\n" expected = ["line1", "\r\n", "line2", "\r\n", ""] actual = helpers.split_lines(body) assert actual == expected
def test_two_lines_no_eof_linesep_dos(self): """Test two lines without EOF CRLF.""" body = "line1\r\nline2" expected = ["line1", "\r\n", "line2"] actual = helpers.split_lines(body) assert actual == expected
def test_two_lines_eof_linesep_posix(self): """Expect last entry to be empty string when input is newline terminated.""" body = "line1\nline2\n" expected = ["line1", "\n", "line2", "\n", ""] actual = helpers.split_lines(body) assert actual == expected
def test_two_lines_no_eof_linesep_posix(self): """Expect a list of lines and newline characters when given multiple lines.""" body = "line1\nline2" expected = ["line1", "\n", "line2"] actual = helpers.split_lines(body) assert actual == expected
def test_single_line_no_eof_linesep(self): """Expect a single string entry when provided with a string with no newlines.""" body = "line1" expected = ["line1"] actual = helpers.split_lines(body) assert actual == expected
def test_empty_body(self): """Expect a single, empty string entry when given an empty body.""" body = "" expected = [""] actual = helpers.split_lines(body) assert actual == expected