]> granicus.if.org Git - python/commitdiff
Issue27139 patch by Julio C Cardoza.
authorSteven D'Aprano <steve@pearwood.info>
Thu, 7 Jul 2016 16:38:45 +0000 (02:38 +1000)
committerSteven D'Aprano <steve@pearwood.info>
Thu, 7 Jul 2016 16:38:45 +0000 (02:38 +1000)
Lib/test/test_statistics.py

index 5dd50483f2033c1b4b18f0b040c3b451f3e87913..4e03d983d33c48ae1fb3ef4f75f8d70c902dc027 100644 (file)
@@ -1600,6 +1600,22 @@ class TestMedianGrouped(TestMedian):
         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.