Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-119189: Add more tests for mixed Fraction arithmetic #119236

Merged

Conversation

serhiy-storchaka
Copy link
Member

@serhiy-storchaka serhiy-storchaka commented May 20, 2024

Copy link
Member

@mdickinson mdickinson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM; two nitpick-level comments.

@serhiy-storchaka serhiy-storchaka force-pushed the tests-fractions-mixed-arithmetic branch from dc34aa1 to c1f6081 Compare May 20, 2024 18:37
@serhiy-storchaka serhiy-storchaka merged commit fe67af1 into python:main May 20, 2024
31 checks passed
@miss-islington-app
Copy link

Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12, 3.13.
🐍🍒⛏🤖

@serhiy-storchaka serhiy-storchaka deleted the tests-fractions-mixed-arithmetic branch May 20, 2024 19:34
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request May 20, 2024
…GH-119236)

(cherry picked from commit fe67af1)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request May 20, 2024
…GH-119236)

(cherry picked from commit fe67af1)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
@bedevere-app
Copy link

bedevere-app bot commented May 20, 2024

GH-119255 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.13 bugs and security fixes label May 20, 2024
@bedevere-app
Copy link

bedevere-app bot commented May 20, 2024

GH-119256 is a backport of this pull request to the 3.12 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.12 bug and security fixes label May 20, 2024
serhiy-storchaka added a commit that referenced this pull request May 20, 2024
…9236) (GH-119256)

(cherry picked from commit fe67af1)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
serhiy-storchaka added a commit that referenced this pull request May 20, 2024
…9236) (GH-119255)

(cherry picked from commit fe67af1)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
@scoder
Copy link
Contributor

scoder commented Nov 28, 2024

I noticed that the newly added tests are written the wrong way around. When a test fails, it says something like

Traceback (most recent call last):
  File "test_fractions.py", line …, in testMixedDivision
    self.assertTypedEquals(F(3, 2) / Rat(3, 5), Rat(15, 6))
  File "test_fractions.py", line …, in assertTypedEquals
    self.assertEqual(type(expected), type(actual))
AssertionError: <class 'Fraction'> != <class '__main__.Rat'>

Note how expected and actual are reversed here. This is misleading and it took me a couple of looks to understand that I was simply searching for the wrong kind of bug. The previously existing tests were apparently written the other way round:

        self.assertTypedEquals(F(1, 10), F(1, 10) / 1)  # existing

versus

        self.assertTypedEquals(F(3, 2) / DummyFraction(3, 5), F(5, 2))  # new

scoder added a commit to scoder/quicktions that referenced this pull request Nov 28, 2024
@serhiy-storchaka
Copy link
Member Author

The normal order for assertEqual() is actual, expected. But some old tests are written with other order. We do not touch them to avoid code churn. It seems that old tests here were written in such order, but assertTy po edEquals then reverted the order .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip news tests Tests in the Lib/test dir
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants