classification
Title: turtle: tests for Vec2D.__abs__ are too strict
Type: behavior Stage: resolved
Components: Versions: Python 3.11, Python 3.10, Python 3.9
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: loganasherjones, lukasz.langa, mark.dickinson, miss-islington
Priority: normal Keywords: easy, patch

Created on 2021-07-24 16:46 by mark.dickinson, last changed 2021-07-26 15:59 by lukasz.langa. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 27343 merged loganasherjones, 2021-07-25 00:22
PR 27361 merged miss-islington, 2021-07-26 15:21
PR 27362 merged miss-islington, 2021-07-26 15:21
Messages (5)
msg398166 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2021-07-24 16:46
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).
msg398233 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2021-07-26 15:21
New changeset 3f135c073a53793ec68902f6b513934ddff47235 by Logan Jones in branch 'main':
bpo-44734: Fix precision in turtle tests (GH-27343)
https://github.com/python/cpython/commit/3f135c073a53793ec68902f6b513934ddff47235
msg398235 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2021-07-26 15:55
New changeset 16a174f7bac481ff6f859179b30a74d867747137 by Miss Islington (bot) in branch '3.10':
bpo-44734: Fix precision in turtle tests (GH-27343) (GH-27361)
https://github.com/python/cpython/commit/16a174f7bac481ff6f859179b30a74d867747137
msg398236 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2021-07-26 15:56
New changeset 7b2185b8e495daed30b50fe89f3ada0dc0129b62 by Miss Islington (bot) in branch '3.9':
bpo-44734: Fix precision in turtle tests (GH-27343) (GH-27362)
https://github.com/python/cpython/commit/7b2185b8e495daed30b50fe89f3ada0dc0129b62
msg398237 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2021-07-26 15:59
Thanks! ✨ 🍰 ✨
History
Date User Action Args
2021-07-26 15:59:55lukasz.langasetmessages: + msg398237
2021-07-26 15:59:48lukasz.langasetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2021-07-26 15:56:23lukasz.langasetmessages: + msg398236
2021-07-26 15:56:00lukasz.langasetmessages: + msg398235
2021-07-26 15:21:25miss-islingtonsetpull_requests: + pull_request25902
2021-07-26 15:21:19miss-islingtonsetnosy: + miss-islington
pull_requests: + pull_request25901
2021-07-26 15:21:17lukasz.langasetnosy: + lukasz.langa
messages: + msg398233
2021-07-25 00:22:31loganasherjonessetkeywords: + patch
nosy: + loganasherjones

pull_requests: + pull_request25885
stage: patch review
2021-07-24 16:49:25mark.dickinsonsetkeywords: + easy
2021-07-24 16:47:06mark.dickinsonsettype: behavior
versions: + Python 3.9, Python 3.10, Python 3.11
2021-07-24 16:46:47mark.dickinsoncreate