def test_split_long_unicode(self): """Are words with multi-byte chars split correctly?""" # Repeated failures lead to success. msg = "失敗を繰り返すことで、成功に至る。" expected = [to_bytes("失敗を繰り返"), to_bytes("すことで、成"), to_bytes("功に至る。")] messages = chunk_message(msg, max_length=20) self.assertEqual(messages, expected)
def test_split_long_word(self): """Does it split long words?""" msg = 'Sup Llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch?' expected = [ b'Sup', b'Llanfairpwllgwyngyll', b'gogerychwyrndrobwlll', b'lantysiliogogogoch?', ] messages = chunk_message(msg, max_length=20) self.assertEqual(messages, expected)
def test_split_long_line(self): """Does it split long lines?""" msg = 'Message to be split into chunks of twenty characters or less.' expected = [ b'Message to be split', b'into chunks of', b'twenty characters or', b'less.', ] messages = chunk_message(msg, max_length=20) self.assertEqual(messages, expected)
def test_split_linefeeds(self): """Does it split on newline chars?""" msg = 'A message\rsplit over\nmany lines\r\nwith odd linebreaks.' expected = [ b'A message', b'split over', b'many lines', b'with odd linebreaks.', ] messages = chunk_message(msg, max_length=100) self.assertEqual(messages, expected)
def test_return_type(self): """Does it return a list of bytes objects?""" expected = [b'Just a simple message'] messages = chunk_message('Just a simple message', max_length=100) self.assertEqual(messages, expected)
def test_split_linefeeds(self): """Does it split on newline chars?""" msg = "A message\rsplit over\nmany lines\r\nwith odd linebreaks." expected = [b"A message", b"split over", b"many lines", b"with odd linebreaks."] messages = chunk_message(msg, max_length=100) self.assertEqual(messages, expected)
def test_split_long_word(self): """Does it split long words?""" msg = "Sup Llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch?" expected = [b"Sup", b"Llanfairpwllgwyngyll", b"gogerychwyrndrobwlll", b"lantysiliogogogoch?"] messages = chunk_message(msg, max_length=20) self.assertEqual(messages, expected)
def test_split_long_line(self): """Does it split long lines?""" msg = "Message to be split into chunks of twenty characters or less." expected = [b"Message to be split", b"into chunks of", b"twenty characters or", b"less."] messages = chunk_message(msg, max_length=20) self.assertEqual(messages, expected)