[Python-checkins] bpo-44734: Fix precision in turtle tests (GH-27343)

ambv webhook-mailer at python.org
Mon Jul 26 11:21:18 EDT 2021


https://github.com/python/cpython/commit/3f135c073a53793ec68902f6b513934ddff47235
commit: 3f135c073a53793ec68902f6b513934ddff47235
branch: main
author: Logan Jones <loganasherjones at gmail.com>
committer: ambv <lukasz at langa.pl>
date: 2021-07-26T17:21:09+02:00
summary:

bpo-44734: Fix precision in turtle tests (GH-27343)

files:
A Misc/NEWS.d/next/Tests/2021-07-24-20-09-15.bpo-44734.KKsNOV.rst
M Lib/test/test_turtle.py

diff --git a/Lib/test/test_turtle.py b/Lib/test/test_turtle.py
index 86d65075144753..8d6d3a7bd806ca 100644
--- a/Lib/test/test_turtle.py
+++ b/Lib/test/test_turtle.py
@@ -235,17 +235,9 @@ def test_vector_negative(self):
         self.assertVectorsAlmostEqual(-vec, expected)
 
     def test_distance(self):
-        vec = Vec2D(6, 8)
-        expected = 10
-        self.assertEqual(abs(vec), expected)
-
-        vec = Vec2D(0, 0)
-        expected = 0
-        self.assertEqual(abs(vec), expected)
-
-        vec = Vec2D(2.5, 6)
-        expected = 6.5
-        self.assertEqual(abs(vec), expected)
+        self.assertEqual(abs(Vec2D(6, 8)), 10)
+        self.assertEqual(abs(Vec2D(0, 0)), 0)
+        self.assertAlmostEqual(abs(Vec2D(2.5, 6)), 6.5)
 
     def test_rotate(self):
 
diff --git a/Misc/NEWS.d/next/Tests/2021-07-24-20-09-15.bpo-44734.KKsNOV.rst b/Misc/NEWS.d/next/Tests/2021-07-24-20-09-15.bpo-44734.KKsNOV.rst
new file mode 100644
index 00000000000000..94e9ce08f4bf6b
--- /dev/null
+++ b/Misc/NEWS.d/next/Tests/2021-07-24-20-09-15.bpo-44734.KKsNOV.rst
@@ -0,0 +1 @@
+Fixed floating point precision issue in turtle tests.



More information about the Python-checkins mailing list