summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_fractions.py
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2008-07-10 14:34:57 (GMT)
committerRaymond Hettinger <python@rcn.com>2008-07-10 14:34:57 (GMT)
commitb01713e7dc26721e821a2b3ed8a67600d68940fb (patch)
tree719287beb7ed98a8e8aecfe2e647314325569d3f /Lib/test/test_fractions.py
parent3cd1e42dca01308a9f5897ba2efc2aab0bebb661 (diff)
downloadcpython-b01713e7dc26721e821a2b3ed8a67600d68940fb.zip
cpython-b01713e7dc26721e821a2b3ed8a67600d68940fb.tar.gz
cpython-b01713e7dc26721e821a2b3ed8a67600d68940fb.tar.bz2
Issue 3285: Fractions from_float() and from_decimal() accept Integral arguments.
Diffstat (limited to 'Lib/test/test_fractions.py')
-rw-r--r--Lib/test/test_fractions.py12
1 files changed, 4 insertions, 8 deletions
diff --git a/Lib/test/test_fractions.py b/Lib/test/test_fractions.py
index d61294f..979fef7 100644
--- a/Lib/test/test_fractions.py
+++ b/Lib/test/test_fractions.py
@@ -137,10 +137,8 @@ class FractionTest(unittest.TestCase):
self.assertNotEquals(F(4, 2), r)
def testFromFloat(self):
- self.assertRaisesMessage(
- TypeError, "Fraction.from_float() only takes floats, not 3 (int)",
- F.from_float, 3)
-
+ self.assertRaises(TypeError, F.from_float, 3+4j)
+ self.assertEquals((10, 1), _components(F.from_float(10)))
self.assertEquals((0, 1), _components(F.from_float(-0.0)))
self.assertEquals((10, 1), _components(F.from_float(10.0)))
self.assertEquals((-5, 2), _components(F.from_float(-2.5)))
@@ -164,10 +162,8 @@ class FractionTest(unittest.TestCase):
F.from_float, nan)
def testFromDecimal(self):
- self.assertRaisesMessage(
- TypeError,
- "Fraction.from_decimal() only takes Decimals, not 3 (int)",
- F.from_decimal, 3)
+ self.assertRaises(TypeError, F.from_decimal, 3+4j)
+ self.assertEquals(F(10, 1), F.from_decimal(10))
self.assertEquals(F(0), F.from_decimal(Decimal("-0")))
self.assertEquals(F(5, 10), F.from_decimal(Decimal("0.5")))
self.assertEquals(F(5, 1000), F.from_decimal(Decimal("5e-3")))