diff options
author | Mark Dickinson <dickinsm@gmail.com> | 2008-02-02 17:16:13 (GMT) |
---|---|---|
committer | Mark Dickinson <dickinsm@gmail.com> | 2008-02-02 17:16:13 (GMT) |
commit | 1dabdb25f83d55737c2154b63bc463240fd7bc03 (patch) | |
tree | 95d920acab8e1d161cbd81371319aa4b55d61ea5 /Lib/test/test_rational.py | |
parent | 5a6cfee6320383ccc20d9fefbd0ebf1555b17909 (diff) | |
download | cpython-1dabdb25f83d55737c2154b63bc463240fd7bc03.zip cpython-1dabdb25f83d55737c2154b63bc463240fd7bc03.tar.gz cpython-1dabdb25f83d55737c2154b63bc463240fd7bc03.tar.bz2 |
Make the Rational constructor accept '3.' and '.2' as well as '3.2'.
Diffstat (limited to 'Lib/test/test_rational.py')
-rw-r--r-- | Lib/test/test_rational.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/Lib/test/test_rational.py b/Lib/test/test_rational.py index 1c37874..5679c5a 100644 --- a/Lib/test/test_rational.py +++ b/Lib/test/test_rational.py @@ -78,6 +78,8 @@ class RationalTest(unittest.TestCase): self.assertEquals((16, 5), _components(R(" 3.2 "))) self.assertEquals((-16, 5), _components(R(u" -3.2 "))) + self.assertEquals((-3, 1), _components(R(u" -3. "))) + self.assertEquals((3, 5), _components(R(u" .6 "))) self.assertRaisesMessage( @@ -113,6 +115,10 @@ class RationalTest(unittest.TestCase): # Don't accept combinations of decimals and rationals. ValueError, "Invalid literal for Rational: 3.2/7", R, "3.2/7") + self.assertRaisesMessage( + # Allow 3. and .3, but not . + ValueError, "Invalid literal for Rational: .", + R, ".") def testImmutable(self): r = R(7, 3) |