def test_raises_error_when_field_is_none() -> None:
        """Test that an error is raised when a required field is None in strict mode."""
        metric_cls = create_anomalib_metric(DummyMetric)

        metric = metric_cls(fields=["pred_score"])
        batch = ImageBatch(image=torch.rand(4, 3, 10, 10), pred_score=None)  # batch where field is None
        with pytest.raises(ValueError, match="instance does not have a value for field with name"):
            metric.update(batch)
        assert metric._update_count == 0  # noqa: SLF001
        assert metric.update_called is False
Test that an error is raised when a required field is None in strict mode.
tests/unit/metrics/test_anomalib_metric.py