Merged revisions 60475-60479,60481-60488 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r60482 | raymond.hettinger | 2008-01-31 23:07:16 +0100 (Thu, 31 Jan 2008) | 1 line
Minor wordsmithing on docstring
........
r60483 | mark.dickinson | 2008-01-31 23:17:37 +0100 (Thu, 31 Jan 2008) | 5 lines
Issue #1678380. Fix a bug that identifies 0j and -0j when they appear
in the same code unit. The fix is essentially the same as the fix for a
previous bug identifying 0. and -0.
........
r60484 | christian.heimes | 2008-02-01 00:08:23 +0100 (Fri, 01 Feb 2008) | 1 line
Fixed bug #1983: Return from fork() is pid_t, not int
........
r60486 | jeffrey.yasskin | 2008-02-01 07:22:46 +0100 (Fri, 01 Feb 2008) | 4 lines
Move __builtins__.trunc() to math.trunc() per
http://mail.python.org/pipermail/python-dev/2008-January/076626.html and issue
1965.
........
r60487 | jeffrey.yasskin | 2008-02-01 08:05:46 +0100 (Fri, 01 Feb 2008) | 3 lines
Roll back r60248. It's useful to encourage users not to change Rational
instances.
........
r60488 | neal.norwitz | 2008-02-01 08:22:59 +0100 (Fri, 01 Feb 2008) | 1 line
Fix refleak
........
diff --git a/Lib/test/test_rational.py b/Lib/test/test_rational.py
index 284a42a..c9a129f 100644
--- a/Lib/test/test_rational.py
+++ b/Lib/test/test_rational.py
@@ -117,6 +117,17 @@
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)",
@@ -193,7 +204,7 @@
self.assertEqual(R.from_float(0.0).approximate(10000), R(0))
def testConversions(self):
- self.assertTypedEquals(-1, trunc(R(-11, 10)))
+ self.assertTypedEquals(-1, math.trunc(R(-11, 10)))
self.assertTypedEquals(-2, math.floor(R(-11, 10)))
self.assertTypedEquals(-1, math.ceil(R(-11, 10)))
self.assertTypedEquals(-1, math.ceil(R(-10, 10)))
@@ -337,11 +348,11 @@
# Because 10**23 can't be represented exactly as a float:
self.assertFalse(R(10**23) == float(10**23))
# The first test demonstrates why these are important.
- self.assertFalse(1e23 < float(R(trunc(1e23) + 1)))
- self.assertTrue(1e23 < R(trunc(1e23) + 1))
- self.assertFalse(1e23 <= R(trunc(1e23) - 1))
- self.assertTrue(1e23 > R(trunc(1e23) - 1))
- self.assertFalse(1e23 >= R(trunc(1e23) + 1))
+ self.assertFalse(1e23 < float(R(math.trunc(1e23) + 1)))
+ self.assertTrue(1e23 < R(math.trunc(1e23) + 1))
+ self.assertFalse(1e23 <= R(math.trunc(1e23) - 1))
+ self.assertTrue(1e23 > R(math.trunc(1e23) - 1))
+ self.assertFalse(1e23 >= R(math.trunc(1e23) + 1))
def testBigComplexComparisons(self):
self.assertFalse(R(10**23) == complex(10**23))