def test_add_duplicate(self): sub = Substitutions() sub.add_substitute("$FIRSTNAME", "Fred") sub.add_substitute("$FIRSTNAME", "Fred") self.assertTrue(sub.has_substitute("$FIRSTNAME"))
def test_basics(self): sub = Substitutions() sub.add_substitute("$FIRSTNAME", "Fred") sub.add_substitute("$SURNAME", "West") sub.add_substitute("$WIFE", "Mary") self.assertTrue(sub.has_substitute("$FIRSTNAME")) self.assertFalse(sub.has_substitute("$FRED")) self.assertEquals("Fred", sub.get_substitute("$FIRSTNAME")) self.assertEquals("West", sub.get_substitute("$SURNAME")) self.assertEquals("Mary", sub.get_substitute("$WIFE")) with self.assertRaises(ValueError): sub.get_substitute("$NUMBER") sub.empty() self.assertFalse(sub.has_substitute("$FIRSTNAME")) self.assertFalse(sub.has_substitute("$SURNAME")) self.assertFalse(sub.has_substitute("$WIFE"))