def test_iadd(self): feature = Feature([('bob', 3), ('joe', 1), ('bobert', 1)]) feature += [('bob', 1)] self.assertEqual(feature.value('bob'), 4) feature += ['bob'] self.assertEqual(feature.value('bob'), 5) feature += 'bob' self.assertEqual(feature.value('bob'), 6)
def test_isub(self): feature = Feature([('bob', 3), ('joe', 1), ('bobert', 1)]) feature -= [('bob', 1)] self.assertEqual(feature.value('bob'), 2) feature -= ['bob'] self.assertEqual(feature.value('bob'), 1) feature -= 'bob' self.assertEqual(feature.value('bob'), 0)
def test_extend(self): feature = Feature([('bob', 3), ('joe', 1), ('bobert', 1)]) feature.extend([('bob', 1)]) self.assertEqual(feature.value('bob'), 4) feature.extend(['bob']) self.assertEqual(feature.value('bob'), 5) feature.extend('bob') self.assertEqual(feature.value('bob'), 6)