summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_math.py
diff options
context:
space:
mode:
authorRaymond Hettinger <rhettinger@users.noreply.github.com>2019-07-27 21:04:29 (GMT)
committerGitHub <noreply@github.com>2019-07-27 21:04:29 (GMT)
commit6b5f1b496f0b20144592b640b9c975df43a29eb0 (patch)
tree02675047df60efacb1a5f449c1c373a7485e7330 /Lib/test/test_math.py
parent3221a63c69268a9362802371a616f49d522a5c4f (diff)
downloadcpython-6b5f1b496f0b20144592b640b9c975df43a29eb0.zip
cpython-6b5f1b496f0b20144592b640b9c975df43a29eb0.tar.gz
cpython-6b5f1b496f0b20144592b640b9c975df43a29eb0.tar.bz2
bpo-37691: Let math.dist() accept sequences and iterables for coordinates (GH-14975)
Diffstat (limited to 'Lib/test/test_math.py')
-rw-r--r--Lib/test/test_math.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/Lib/test/test_math.py b/Lib/test/test_math.py
index 567a5c6..c237bc1 100644
--- a/Lib/test/test_math.py
+++ b/Lib/test/test_math.py
@@ -833,6 +833,10 @@ class MathTests(unittest.TestCase):
sqrt(sum((px - qx) ** 2.0 for px, qx in zip(p, q)))
)
+ # Test non-tuple inputs
+ self.assertEqual(dist([1.0, 2.0, 3.0], [4.0, 2.0, -1.0]), 5.0)
+ self.assertEqual(dist(iter([1.0, 2.0, 3.0]), iter([4.0, 2.0, -1.0])), 5.0)
+
# Test allowable types (those with __float__)
self.assertEqual(dist((14.0, 1.0), (2.0, -4.0)), 13.0)
self.assertEqual(dist((14, 1), (2, -4)), 13)
@@ -873,8 +877,6 @@ class MathTests(unittest.TestCase):
dist((1, 2, 3), (4, 5, 6), (7, 8, 9))
with self.assertRaises(TypeError): # Scalars not allowed
dist(1, 2)
- with self.assertRaises(TypeError): # Lists not allowed
- dist([1, 2, 3], [4, 5, 6])
with self.assertRaises(TypeError): # Reject values without __float__
dist((1.1, 'string', 2.2), (1, 2, 3))
with self.assertRaises(ValueError): # Check dimension agree