diff options
author | Stephan Richter <stephan.richter@gmail.com> | 2007-06-25 22:25:44 +0000 |
---|---|---|
committer | Stephan Richter <stephan.richter@gmail.com> | 2007-06-25 22:25:44 +0000 |
commit | f6a0a6b33dd98f92f5dbbea5db8f45286b0bd9e5 (patch) | |
tree | 7ad949d76d035fc69d11f07f19286a5728481b32 /src/zope/i18n/tests/test_formats.py | |
parent | a3968d3e68f2779ede2f4993e233964af7f15065 (diff) | |
download | zope-i18n-f6a0a6b33dd98f92f5dbbea5db8f45286b0bd9e5.tar.gz |
Provided hook, so that numbers can be parsed into custom types, such as
decimal.
Diffstat (limited to 'src/zope/i18n/tests/test_formats.py')
-rw-r--r-- | src/zope/i18n/tests/test_formats.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/zope/i18n/tests/test_formats.py b/src/zope/i18n/tests/test_formats.py index b820abe..27d0bd4 100644 --- a/src/zope/i18n/tests/test_formats.py +++ b/src/zope/i18n/tests/test_formats.py @@ -15,6 +15,7 @@ $Id$ """ +import decimal import os import datetime import pytz @@ -980,6 +981,14 @@ class TestNumberFormat(TestCase): symbols={'decimal': '.', 'group': ',', 'exponential': 'X'}) self.assertEqual(format.parse('1.2X11', '#.#E0'), 1.2e11) + def testChangeOutputType(self): + format = NumberFormat() + format.type = decimal.Decimal + self.assertEqual(format.parse('23341', '###0'), + decimal.Decimal('23341')) + self.assertEqual(format.parse('233.41', '###0.00'), + decimal.Decimal('233.41')) + def testFormatSimpleInteger(self): self.assertEqual(self.format.format(23341, '###0'), '23341') |