def test_when_pencil_write_at_is_passed_a_string_and_an_index_it_will_write_the_string_on_the_paper_at_that_index_on_white_space(self): paper = Paper() paper.text = "An a day keeps the doctor away" self.pencil.write_at(paper, "onion", 3) self.assertEqual(paper.text, "An onion a day keeps the doctor away")
def test_when_pencil_write_at_is_passed_a_string_and_an_index_that_is_in_bounds_but_string_len_plus_index_is_greater_than_paper_text_length_it_overwrites_and_addes_on(self): paper = Paper() paper.text = "An apple a day keeps the doctor away" self.pencil.write_at(paper, "from coming around.", 32) self.assertEqual(paper.text, "An apple a day keeps the doctor @@@@ coming around.")
def test_when_pencil_write_at_is_passed_a_string_and_an_index_greater_than_paper_text_length_it_adds_text_to_end(self): paper = Paper() paper.text = "An apple a day keeps the doctor away" self.pencil.write_at(paper, ", don't you know.", 40) self.assertEqual(paper.text, "An apple a day keeps the doctor away, don't you know.")
def test_when_pencil_write_at_is_passed_a_string_and_an_index_it_will_write_the_string_on_the_paper_at_that_index_and_overwrite_filled_spaces_with_symbol(self): paper = Paper() paper.text = "An a day keeps the doctor away" self.pencil.write_at(paper, "artichoke", 3) self.assertEqual(paper.text, "An artich@k@ay keeps the doctor away")
def test_paper_text_should_be_set_with_text_property(self): paper = Paper() paper.text = 'abc' self.assertEqual(paper.text, 'abc')
def test_when_write_is_passed_string_it_adds_string_to_text_variable_in_the_paper_instance_with_existing_text( self): paper = Paper() paper.text = "Hello " paper.write("World!") self.assertEqual(paper.text, "Hello World!")
def test_when_pencil_write_at_is_passed_a_string_and_an_index_less_than_zero_raises_index_error(self): paper = Paper() paper.text = "An apple a day keeps the doctor away" self.assertRaises(IndexError, lambda: self.pencil.write_at(paper, "Remember, a", -10))