def test_remove(self) -> None: i = MemoryDescriptorSet() descrs = [random_descriptor() for _ in range(100)] i.add_many_descriptors(descrs) self.assertEqual(len(i), 100) self.assertEqual(list(i.iterdescriptors()), descrs) # remove singles i.remove_descriptor(descrs[0].uuid()) self.assertEqual(len(i), 99) self.assertEqual(set(i.iterdescriptors()), set(descrs[1:])) # remove many rm_d = descrs[slice(45, 80, 3)] i.remove_many_descriptors((d.uuid() for d in rm_d)) self.assertEqual(len(i), 99 - len(rm_d)) self.assertEqual(set(i.iterdescriptors()), set(descrs[1:]).difference(rm_d))
def test_iterdescrs(self) -> None: i = MemoryDescriptorSet() descrs = [random_descriptor() for _ in range(100)] i.add_many_descriptors(descrs) self.assertEqual(set(i.iterdescriptors()), set(descrs))