def _check_rename(self, DATA, tag0, tag1, expected_diff): edited, count = graph.edit_text_tree_rename(DATA, tag0, tag1) # this is simple test, assume not 2 word tags data_words = DATA.lower().split() edited_words = edited.lower().split() ltag0 = tag0.lower() ltag1 = tag1.lower() self.assertEqual(count, len(expected_diff)) self.assertTrue(ltag0 not in edited_words) if ltag0 in data_words: self.assertTrue(ltag1 in edited_words) self.assertEqual(len(DATA.splitlines()), len(edited.splitlines())) # check line diff diff = [] for i,line1,line2 in zip(xrange(9999), DATA.splitlines(), edited.splitlines()): if line1 != line2: diff.append(i) self.assertEqual(expected_diff, diff)
def renameTag(self, tag0, tag1): text= self.getDescription() edited, count = graph.edit_text_tree_rename(text, tag0, tag1) if count > 0: self.setDescription(edited)