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

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
This commit is contained in:
Kirill Podoprigora 2024-06-07 11:03:28 +03:00 committed by GitHub
parent bd826b9c77
commit 57ad769076
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 20 additions and 7 deletions

View file

@ -949,6 +949,12 @@ class RoundTestCase(unittest.TestCase):
self.assertEqual(x, 2)
self.assertIsInstance(x, int)
def test_round_with_none_arg_direct_call(self):
for val in [(1.0).__round__(None),
round(1.0),
round(1.0, None)]:
self.assertEqual(val, 1)
self.assertIs(type(val), int)
# Beginning with Python 2.6 float has cross platform compatible
# ways to create and represent inf and nan