mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
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:
parent
bd826b9c77
commit
57ad769076
6 changed files with 20 additions and 7 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue