mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Roll back r60248. It's useful to encourage users not to change Rational
instances.
This commit is contained in:
parent
ca2b69f765
commit
dc2964b0d8
2 changed files with 22 additions and 3 deletions
|
@ -119,6 +119,17 @@ class RationalTest(unittest.TestCase):
|
|||
r.__init__(2, 15)
|
||||
self.assertEquals((7, 3), _components(r))
|
||||
|
||||
self.assertRaises(AttributeError, setattr, r, 'numerator', 12)
|
||||
self.assertRaises(AttributeError, setattr, r, 'denominator', 6)
|
||||
self.assertEquals((7, 3), _components(r))
|
||||
|
||||
# But if you _really_ need to:
|
||||
r._numerator = 4
|
||||
r._denominator = 2
|
||||
self.assertEquals((4, 2), _components(r))
|
||||
# Which breaks some important operations:
|
||||
self.assertNotEquals(R(4, 2), r)
|
||||
|
||||
def testFromFloat(self):
|
||||
self.assertRaisesMessage(
|
||||
TypeError, "Rational.from_float() only takes floats, not 3 (int)",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue