GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-119189: Add more tests for mixed Fraction arithmetic by serhiy-storchaka · Pull Request #119236 · python/cpython

Conversation

@serhiy-storchaka

@serhiy-storchaka serhiy-storchaka commented May 20, 2024 •
edited by bedevere-app Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member
  • Issue: Fraction wrongfully gets casted into float when given as argument to __rpow__ #119189

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@serhiy-storchaka
pythongh-119189: Add more tests for mixed Fraction arithmetic
317c1c6
@serhiy-storchaka serhiy-storchaka added tests Tests in the Lib/test dir skip news needs backport to 3.12 only security fixes needs backport to 3.13 only security fixes labels May 20, 2024
@serhiy-storchaka
serhiy-storchaka requested a review from mdickinson May 20, 2024 17:21
@bedevere-app bedevere-app Bot added the awaiting core review label May 20, 2024
@bedevere-app bedevere-app Bot mentioned this pull request May 20, 2024
Fraction wrongfully gets casted into float when given as argument to __rpow__ #119189
Closed
mdickinson
mdickinson approved these changes May 20, 2024
View reviewed changes

@mdickinson mdickinson left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this 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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Lib/test/test_fractions.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/test/test_fractions.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting core review labels May 20, 2024
@serhiy-storchaka
Address reviwe comments. Replace class One with class Symbolic.
c1f6081
@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
@miss-islington-app

miss-islington-app Bot commented May 20, 2024

Copy link
Copy Markdown

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the awaiting merge label May 20, 2024
@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
@serhiy-storchaka @miss-islington
pythongh-119189: Add more tests for mixed Fraction arithmetic (python…
309459a
…GH-119236)

(cherry picked from commit fe67af1)

Co-authored-by: Serhiy Storchaka <[email protected]>
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request May 20, 2024
@serhiy-storchaka @miss-islington
pythongh-119189: Add more tests for mixed Fraction arithmetic (python…
3978107
…GH-119236)

(cherry picked from commit fe67af1)

Co-authored-by: Serhiy Storchaka <[email protected]>
@bedevere-app

bedevere-app Bot commented May 20, 2024

Copy link
Copy Markdown

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the needs backport to 3.13 only security fixes label May 20, 2024
@bedevere-app

bedevere-app Bot commented May 20, 2024

Copy link
Copy Markdown

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the needs backport to 3.12 only security fixes label May 20, 2024
serhiy-storchaka added a commit that referenced this pull request May 20, 2024
@miss-islington @serhiy-storchaka
[3.12] gh-119189: Add more tests for mixed Fraction arithmetic (GH-11…
f489911
…9236) (GH-119256)

(cherry picked from commit fe67af1)

Co-authored-by: Serhiy Storchaka <[email protected]>
serhiy-storchaka added a commit that referenced this pull request May 20, 2024
@miss-islington @serhiy-storchaka
[3.13] gh-119189: Add more tests for mixed Fraction arithmetic (GH-11…
572b0b0
…9236) (GH-119255)

(cherry picked from commit fe67af1)

Co-authored-by: Serhiy Storchaka <[email protected]>
@JelleZijlstra JelleZijlstra mentioned this pull request May 28, 2024
backport a9a74da 3.13 #119642
Closed
estyxx pushed a commit to estyxx/cpython that referenced this pull request Jul 17, 2024
@serhiy-storchaka @estyxx
pythongh-119189: Add more tests for mixed Fraction arithmetic (python…
e065d35
…GH-119236)
@scoder

scoder commented Nov 28, 2024

Copy link
Copy Markdown
Contributor

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
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

scoder added a commit to scoder/quicktions that referenced this pull request Nov 28, 2024
@scoder
Fix type interaction with other Rational classes.
e965299
See python/cpython#119236
@serhiy-storchaka

serhiy-storchaka commented Dec 3, 2024

Copy link
Copy Markdown
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 .

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

1 more reviewer
@mdickinson mdickinson mdickinson approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

skip news tests Tests in the Lib/test dir

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@serhiy-storchaka @scoder @mdickinson
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.