def test_eq(self): fg = FeatureGroup('NUMBER', 'singular', 'plural') sg = Feature('NUMBER', 'singular') pl = Feature('NUMBER', 'plural') self.assertEqual(fg, sg) self.assertEqual(fg, pl) self.assertNotEqual(sg, pl)
def test_contains(self): fs = FeatureSet([self.number.singular, self.person.first]) self.assertEqual(2, len(fs)) self.assertIn(self.number.singular, fs) self.assertNotIn(self.number.plural, fs) self.assertIn(self.number, fs) self.assertEqual(Feature('number', 'plural'), Feature('NUMBER', 'plural')) self.assertNotEqual(Feature('number', 'plural'), Feature('number', 'PLURAL'))
def test_equal(self): singular = Feature('NUMBER', 'singular') plural = Feature('NUMBER', 'plural') number = FeatureGroup('NUMBER', 'singular', 'plural') self.assertEqual(number.singular, singular) self.assertEqual(number.plural, plural) self.assertEqual(number, singular) self.assertEqual(number, plural) self.assertNotEqual(number.singular, number.plural) self.assertNotEqual(singular, plural)
def test_contains(self): singular = Feature('NUMBER', 'singular') plural = Feature('NUMBER', 'plural') dual = Feature('NUMBER', 'dual') number = FeatureGroup('NUMBER', 'singular', 'plural') self.assertIn(singular, number) self.assertIn(plural, number) self.assertNotIn(dual, number) self.assertIn('singular', number) fake = Feature('fake', 'plural') self.assertNotIn(fake, number)
def test_repr(self): singular = Feature('NUMBER', 'singular') self.assertEqual('<Feature NUMBER: singular>', repr(singular))
def test_str(self): singular = Feature('NUMBER', 'singular') self.assertEqual('NUMBER: singular', str(singular))