(original) (raw)
changeset: 102283:4c4f8b0c5b30 parent: 102281:c80054ccbbd8 user: Steven D'Aprano steve@pearwood.info date: Fri Jul 08 02:38:45 2016 +1000 files: Lib/test/test_statistics.py description: Issue27139 patch by Julio C Cardoza. diff -r c80054ccbbd8 -r 4c4f8b0c5b30 Lib/test/test_statistics.py --- a/Lib/test/test_statistics.py Thu Jul 07 18:20:03 2016 +0300 +++ b/Lib/test/test_statistics.py Fri Jul 08 02:38:45 2016 +1000 @@ -1600,6 +1600,22 @@ data = [220, 220, 240, 260, 260, 260, 260, 280, 280, 300, 320, 340] self.assertEqual(self.func(data, 20), 265.0) + def test_data_type_error(self): + # Test median_grouped with str, bytes data types for data and interval + data = ["", "", ""] + self.assertRaises(TypeError, self.func, data) + #--- + data = [b"", b"", b""] + self.assertRaises(TypeError, self.func, data) + #--- + data = [1, 2, 3] + interval = "" + self.assertRaises(TypeError, self.func, data, interval) + #--- + data = [1, 2, 3] + interval = b"" + self.assertRaises(TypeError, self.func, data, interval) + class TestMode(NumericTestCase, AverageMixin, UnivariateTypeMixin): # Test cases for the discrete version of mode. /steve@pearwood.info