From 9b48d46ccf068036aaf733a89591677a9f7b1e5a Mon Sep 17 00:00:00 2001 From: Nikolaus Schuetz Date: Sat, 1 Aug 2026 01:30:12 -0700 Subject: [PATCH] gh-154945: add regression test for NormalDist.quantiles(0) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds test_quantiles_invalid_n to verify that NormalDist.quantiles(n) raises StatisticsError when n < 1, mirroring the module-level quantiles() validation. Currently fails (test is red) — quantiles(0) silently returns [] instead of raising. --- Lib/test/test_statistics.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Lib/test/test_statistics.py b/Lib/test/test_statistics.py index 700c5ac304f7179..34fa33e054bf571 100644 --- a/Lib/test/test_statistics.py +++ b/Lib/test/test_statistics.py @@ -3105,6 +3105,12 @@ def test_quantiles(self): self.assertTrue(all(math.isclose(e, a, abs_tol=0.0001) for e, a in zip(expected, actual))) + def test_quantiles_invalid_n(self): + Z = self.module.NormalDist() + with self.assertRaises(self.module.StatisticsError) as cm: + Z.quantiles(0) + self.assertEqual(str(cm.exception), 'n must be at least 1') + def test_overlap(self): NormalDist = self.module.NormalDist