Ejemplo n.º 1
0
 def test_t_lets_appending_take_over(self):
     assert truncate('I am a long sentence.', 21, ' the cheese!') == 'I am a long sentence.'
     assert truncate('I am a long sentence.', 20, ' the cheese!') == 'I am a the cheese!'
     assert truncate('I am a long sentence.', 19, ' the cheese!') == 'I am a the cheese!'
     assert truncate('I am a long sentence.', 18, ' the cheese!') == 'I am a the cheese!'
     assert truncate('I am a long sentence.', 17, ' the cheese!') == 'I am the cheese!'
     assert truncate('I am a long sentence.', 16, ' the cheese!') == 'I am the cheese!'
     assert truncate('I am a long sentence.', 15, ' the cheese!') == 'I the cheese!'
     assert truncate('I am a long sentence.', 14, ' the cheese!') == 'I the cheese!'
     assert truncate('I am a long sentence.', 13, ' the cheese!') == 'I the cheese!'
     assert truncate('I am a long sentence.', 12, ' the cheese!') == ' the cheese!'
     assert truncate('I am a long sentence.', 11, ' the cheese!') == ' the cheese!'
     assert truncate('I am a long sentence.', 10, ' the cheese!') == ' the cheese!'
     assert truncate('I am a long sentence.',  9, ' the cheese!') == ' the cheese!'
     assert truncate('I am a long sentence.',  8, ' the cheese!') == ' the cheese!'
     assert truncate('I am a long sentence.',  7, ' the cheese!') == ' the cheese!'
     assert truncate('I am a long sentence.',  6, ' the cheese!') == ' the cheese!'
     assert truncate('I am a long sentence.',  5, ' the cheese!') == ' the cheese!'
     assert truncate('I am a long sentence.',  4, ' the cheese!') == ' the cheese!'
     assert truncate('I am a long sentence.',  3, ' the cheese!') == ' the cheese!'
     assert truncate('I am a long sentence.',  2, ' the cheese!') == ' the cheese!'
     assert truncate('I am a long sentence.',  1, ' the cheese!') == ' the cheese!'
     assert truncate('I am a long sentence.',  0, ' the cheese!') == ' the cheese!'
     assert truncate('I am a long sentence.', -1, ' the cheese!') == ' the cheese!'
     assert truncate('I am a long sentence.', -1000, ' the cheese!') == ' the cheese!'
Ejemplo n.º 2
0
 def test_t_returns_whole_thing_if_possible(self):
     assert truncate('I am a long sentence.', 20) == 'I am a long …'
     assert truncate('I am a long sentence.', 21) == 'I am a long sentence.'
     assert truncate('I am a long sentence.', 22) == 'I am a long sentence.'
     assert truncate('I am a long sentence.', 220000) == 'I am a long sentence.'
Ejemplo n.º 3
0
 def test_t_appends_what_you_like(self):
     assert truncate('I am a long sentence.', 14, ' cheese.') == 'I am a cheese.'
Ejemplo n.º 4
0
 def test_t_finds_word_break_properly(self):
     assert truncate('I am a long sentence.', 12) == 'I am a …'
     assert truncate('I am a long sentence.', 14) == 'I am a long …'
Ejemplo n.º 5
0
 def test_t_splits_words_if_it_has_to(self):
     assert truncate('I_am_a_long_sentence.', 17) == 'I_am_a_long_sen …'
Ejemplo n.º 6
0
 def test_t_truncates(self):
     assert truncate('I am a long sentence.', 13) == 'I am a long …'
Ejemplo n.º 7
0
 def test_t_doesnt_split_words(self):
     assert truncate('I am a long sentence.', 16) == 'I am a long …'
Ejemplo n.º 8
0
 def test_appends_what_you_like(self):
     assert truncate('I am a long sentence.', 14, ' cheese.') == 'I am a cheese.'
Ejemplo n.º 9
0
 def test_lets_appending_take_over(self):
     assert truncate('I am a long sentence.', 21, ' the cheese!') == 'I am a long sentence.'
     assert truncate('I am a long sentence.', 20, ' the cheese!') == 'I am a the cheese!'
     assert truncate('I am a long sentence.', 19, ' the cheese!') == 'I am a the cheese!'
     assert truncate('I am a long sentence.', 18, ' the cheese!') == 'I am a the cheese!'
     assert truncate('I am a long sentence.', 17, ' the cheese!') == 'I am the cheese!'
     assert truncate('I am a long sentence.', 16, ' the cheese!') == 'I am the cheese!'
     assert truncate('I am a long sentence.', 15, ' the cheese!') == 'I the cheese!'
     assert truncate('I am a long sentence.', 14, ' the cheese!') == 'I the cheese!'
     assert truncate('I am a long sentence.', 13, ' the cheese!') == 'I the cheese!'
     assert truncate('I am a long sentence.', 12, ' the cheese!') == ' the cheese!'
     assert truncate('I am a long sentence.', 11, ' the cheese!') == ' the cheese!'
     assert truncate('I am a long sentence.', 10, ' the cheese!') == ' the cheese!'
     assert truncate('I am a long sentence.',  9, ' the cheese!') == ' the cheese!'
     assert truncate('I am a long sentence.',  8, ' the cheese!') == ' the cheese!'
     assert truncate('I am a long sentence.',  7, ' the cheese!') == ' the cheese!'
     assert truncate('I am a long sentence.',  6, ' the cheese!') == ' the cheese!'
     assert truncate('I am a long sentence.',  5, ' the cheese!') == ' the cheese!'
     assert truncate('I am a long sentence.',  4, ' the cheese!') == ' the cheese!'
     assert truncate('I am a long sentence.',  3, ' the cheese!') == ' the cheese!'
     assert truncate('I am a long sentence.',  2, ' the cheese!') == ' the cheese!'
     assert truncate('I am a long sentence.',  1, ' the cheese!') == ' the cheese!'
     assert truncate('I am a long sentence.',  0, ' the cheese!') == ' the cheese!'
     assert truncate('I am a long sentence.', -1, ' the cheese!') == ' the cheese!'
     assert truncate('I am a long sentence.', -1000, ' the cheese!') == ' the cheese!'
Ejemplo n.º 10
0
 def test_returns_whole_thing_if_possible(self):
     assert truncate('I am a long sentence.', 20) == 'I am a long …'
     assert truncate('I am a long sentence.', 21) == 'I am a long sentence.'
     assert truncate('I am a long sentence.', 22) == 'I am a long sentence.'
     assert truncate('I am a long sentence.', 220000) == 'I am a long sentence.'
Ejemplo n.º 11
0
 def test_splits_words_if_it_has_to(self):
     assert truncate('I_am_a_long_sentence.', 17) == 'I_am_a_long_sen …'
Ejemplo n.º 12
0
 def test_finds_word_break_properly(self):
     assert truncate('I am a long sentence.', 12) == 'I am a …'
     assert truncate('I am a long sentence.', 14) == 'I am a long …'
Ejemplo n.º 13
0
 def test_doesnt_split_words(self):
     assert truncate('I am a long sentence.', 16) == 'I am a long …'
Ejemplo n.º 14
0
 def test_truncates(self):
     assert truncate('I am a long sentence.', 13) == 'I am a long …'