def test_hugs_calibration(self):
        """Check that HuggingFace moderation feedback functions produce reasonable values."""

        h = huggingface_provider.Huggingface()

        tests = get_huggingface_tests(h)

        failed_tests = 0
        total_tests = 0
        failed_subtests = []

        for imp, args, expected in tests:
            subtest_name = f"{imp.__name__}-{args}"
            actual = imp(**args)
            if ("language_match" in imp.__name__) or (
                "with_cot_reasons" in imp.__name__
            ):
                actual = actual[0]
            with self.subTest(subtest_name):
                total_tests += 1
                try:
                    self.assertAlmostEqual(actual, expected, delta=0.2)
                except AssertionError:
                    failed_tests += 1
                    failed_subtests.append((subtest_name, actual, expected))

        if failed_tests > 0:
            failed_subtests_str = ", ".join([
                f"{name} (actual: {act}, expected: {exp})"
                for name, act, exp in failed_subtests
            ])
            self.fail(
                f"{h}: {failed_tests}/{total_tests} tests failed ({failed_subtests_str})"
            )
        else:
            print(f"{h}: {total_tests}/{total_tests} tests passed.")
Check that HuggingFace moderation feedback functions produce reasonable values.
tests/e2e/test_providers.py