diff options
author | Neal Norwitz <nnorwitz@gmail.com> | 2005-11-22 05:17:40 (GMT) |
---|---|---|
committer | Neal Norwitz <nnorwitz@gmail.com> | 2005-11-22 05:17:40 (GMT) |
commit | 5898fa2dcd4cfae3429e8789ae067ffe1940a461 (patch) | |
tree | a54b7c992fb9b88924f74626400b547759d1969c /Lib | |
parent | 3b148ca43d6006a4309a23e9ffd0b79be50b3945 (diff) | |
download | cpython-5898fa2dcd4cfae3429e8789ae067ffe1940a461.zip cpython-5898fa2dcd4cfae3429e8789ae067ffe1940a461.tar.gz cpython-5898fa2dcd4cfae3429e8789ae067ffe1940a461.tar.bz2 |
improve test coverage in Python/pystrtod.c and Python/mystrtoul.c.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_builtin.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/Lib/test/test_builtin.py b/Lib/test/test_builtin.py index 52c1fe0..d3eb2af 100644 --- a/Lib/test/test_builtin.py +++ b/Lib/test/test_builtin.py @@ -545,6 +545,34 @@ class BuiltinTest(unittest.TestCase): self.assertEqual(float(unicode(" 3.14 ")), 3.14) self.assertEqual(float(unicode(" \u0663.\u0661\u0664 ",'raw-unicode-escape')), 3.14) + def test_float_with_comma(self): + # set locale to something that doesn't use '.' for the decimal point + try: + import locale + orig_locale = locale.setlocale(locale.LC_NUMERIC, '') + locale.setlocale(locale.LC_NUMERIC, 'fr_FR') + except: + # if we can't set the locale, just ignore this test + return + + try: + self.assertEqual(locale.localeconv()['decimal_point'], ',') + except: + # this test is worthless, just skip it and reset the locale + locale.setlocale(locale.LC_NUMERIC, orig_locale) + return + + try: + self.assertEqual(float(" 3,14 "), 3.14) + self.assertEqual(float(" +3,14 "), 3.14) + self.assertEqual(float(" -3,14 "), -3.14) + self.assertEqual(float(" 0x3.1 "), 3.0625) + self.assertEqual(float(" -0x3.p-1 "), -1.5) + self.assertEqual(float(" 25.e-1 "), 2.5) + self.assertEqual(fcmp(float(" .25e-1 "), .025), 0) + finally: + locale.setlocale(locale.LC_NUMERIC, orig_locale) + def test_floatconversion(self): # Make sure that calls to __float__() work properly class Foo0: @@ -682,6 +710,7 @@ class BuiltinTest(unittest.TestCase): self.assertRaises(TypeError, int, 1, 12) self.assertEqual(int('0123', 0), 83) + self.assertEqual(int('0x123', 16), 291) def test_intconversion(self): # Test __int__() |