def test_remove_trailing_new_line_with_non_empty_byte_string_with_no_new_line( self): """Expect nothing to change.""" test_string = b"Something" expected_string = test_string r = _remove_trailing_new_line(test_string) self.assertEqual(r, expected_string)
def test_remove_trailing_new_line_with_non_empty_byte_string_with_variety_of_new_lines_in_the_middle( self): """Expect nothing to change because the new line is in the middle.""" base_string = b"Something" for n in new_lines_bytes: test_string = base_string + n + base_string expected_string = test_string r = _remove_trailing_new_line(test_string) self.assertEqual(r, expected_string, msg="Test with {0} as new line".format(repr(n)))
def test_remove_trailing_new_line_with_non_empty_byte_string_with_variety_of_new_lines( self): """Expect new lines to be removed at the end of the string.""" expected_str = b"Something" for n in new_lines_bytes: test_string = expected_str + n r = _remove_trailing_new_line(test_string) self.assertEqual( r, expected_str, msg="Test with {0} followed by {1} as new line at the end of str" .format(repr(expected_str), repr(n)))
def test_remove_trailing_new_line_with_empty_byte_string(self): """Expect nothing to change, because empty byte string does not contain trailing new line.""" test_string = b"" expected_string = test_string r = _remove_trailing_new_line(test_string) self.assertEqual(r, expected_string)