8000 gh-120080: Accept ``None`` as a valid argument for direct call of the ``int.__round__`` by Eclips4 · Pull Request #120088 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-120080: Accept None as a valid argument for direct call of the int.__round__ #120088

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

Merged
merged 11 commits into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add a test cases
  • Loading branch information
Eclips4 committed Jun 5, 2024
commit 6cc13fa03d8b312ec0aee8e911e16911c196751c
2 changes: 2 additions & 0 deletions Lib/test/test_float.py
Original file line number Diff line number Diff line change
Expand Up @@ -949,6 +949,8 @@ def test_None_ndigits(self):
self.assertEqual(x, 2)
self.assertIsInstance(x, int)

def test_round_with_none_arg_direct_call(self):
self.assertEqual((1.0).__round__(None), 1.0)

# Beginning with Python 2.6 float has cross platform compatible
# ways to create and represent inf and nan
Expand Down
2 changes: 2 additions & 0 deletions Lib/test/test_int.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,8 @@ def test_issue31619(self):
self.assertEqual(int('1_2_3_4_5_6_7_8_9', 16), 0x123456789)
self.assertEqual(int('1_2_3_4_5_6_7', 32), 1144132807)

def test_round_with_none_arg_direct_call(self):
self.assertEqual((1).__round__(None), 1)

class IntStrDigitLimitsTests(unittest.TestCase):

Expand Down
Loading
0