mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Implement the round functionality for PEP 3141, and add tests for it.
This commit is contained in:
parent
1dd46a048f
commit
ae211f9abf
2 changed files with 39 additions and 2 deletions
|
@ -1474,6 +1474,19 @@ class BuiltinTest(unittest.TestCase):
|
|||
|
||||
self.assertRaises(TypeError, round)
|
||||
|
||||
# test generic rounding delegation for reals
|
||||
class TestRound:
|
||||
def __round__(self):
|
||||
return 23
|
||||
|
||||
class TestNoRound:
|
||||
pass
|
||||
|
||||
self.assertEqual(round(TestRound()), 23)
|
||||
|
||||
self.assertRaises(TypeError, round, 1, 2, 3)
|
||||
self.assertRaises(TypeError, round, TestNoRound())
|
||||
|
||||
def test_setattr(self):
|
||||
setattr(sys, 'spam', 1)
|
||||
self.assertEqual(sys.spam, 1)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue