Author mark.dickinson
Recipients mark.dickinson
Date 2021-07-24.16:46:47
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1627145207.46.0.348646231014.issue44734@roundup.psfhosted.org>
In-reply-to
Content
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).
History
Date User Action Args
2021-07-24 16:46:47mark.dickinsonsetrecipients: + mark.dickinson
2021-07-24 16:46:47mark.dickinsonsetmessageid: <1627145207.46.0.348646231014.issue44734@roundup.psfhosted.org>
2021-07-24 16:46:47mark.dickinsonlinkissue44734 messages
2021-07-24 16:46:47mark.dickinsoncreate