New submission from Mark Dickinson <dicki...@gmail.com>:

>From the tests for Vec2D.__abs__ in the turtle module we have:

    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)

GitHub link: 
https://github.com/python/cpython/blob/8158e059e9952f08d19a18d3e9e021cee2393cd2/Lib/test/test_turtle.py#L237-L248

The first test was reported as failing in issue #44728, with error:

======================================================================
FAIL: test_distance (test.test_turtle.TestVec2D)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/build/python/src/Python-3.9.6/Lib/test/test_turtle.py", line 237, in 
test_distance
    self.assertEqual(abs(vec), expected)
AssertionError: 9.999999999999998 != 10

The first and last test should use assertAlmostEqual with a suitable tolerance 
(the default tolerance is probably fine).

----------
messages: 398166
nosy: mark.dickinson
priority: normal
severity: normal
status: open
title: turtle: tests for Vec2D.__abs__ are too strict

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue44734>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to