def test_when_new_word_is_too_long_it_should_replace_characters_with_at_symbol(self): pencil = Pencil() pencil.write(self.paper, "An a day keeps the doctor away") pencil.edit(self.paper, "artichoke") self.assertEqual("An artich@k@ay keeps the doctor away", self.paper.read())
def test_editing_should_replace_erased_word_with_new_text(self): pencil = Pencil() pencil.write(self.paper, "An a day keeps the doctor away") pencil.edit(self.paper, "onion") self.assertEqual("An onion a day keeps the doctor away", self.paper.read())
def test_when_new_word_goes_beyond_end_of_paper_it_should_be_appended_to_the_end(self): pencil = Pencil() pencil.write(self.paper, "A short phrase") pencil.erase(self.paper, "phrase") pencil.edit(self.paper, "sentence") self.assertEqual("A short sentence", self.paper.read())
def test_editing_replaces_text(initial_text, new_text, output): paper = Paper(initial_text) pencil = Pencil() pencil.edit(paper, new_text) assert paper.buffer == output
def test_edit_writes_spaces_when_out_of_lead(): pencil = Pencil(5) sentence = 'An a day' assert pencil.edit('artichoke', sentence, 3) == 'An artic ay'
def test_overwrites_chars_with_at_sign(): pencil = Pencil() sentence = 'An a day keeps the doctor away' assert pencil.edit('artichoke', sentence, 3) == 'An artich@k@ay keeps the doctor away'
def test_can_write_into_a_whitespace_gap(): pencil = Pencil() sentence = 'An a day keeps the doctor away.' assert pencil.edit('onion', sentence, 3) == 'An onion a day keeps the doctor away.'