def test_add_already_added(self):
        prio_set_list = event._PrioritizedSetList()
        obj = object()
        prio_set_list.add(0, obj)

        with pytest.raises(ValueError) as excinfo:
            prio_set_list.add(0, obj)
        excinfo.match(r"has already been added")

        with pytest.raises(ValueError) as excinfo:
            prio_set_list.add(1, obj)
        excinfo.match(r"has already been added")
def __setattr__(self, name: str, value: Any):
        """Custom __setattr__ to allow access to metrics schema fields."""

        if not self._initialized:
            object.__setattr__(self, name, value)
            return

        if name not in self._metric_fields:
            raise RuntimeError(
                'Field: {} not defined in metirc schema'.format(name))

        self._values[name] = value