[Zope3-checkins] CVS: Zope3/src/zope/i18n/tests - test_formats.py:1.2
Jim Fulton
jim@zope.com
Thu, 9 Jan 2003 09:13:49 -0500
Update of /cvs-repository/Zope3/src/zope/i18n/tests
In directory cvs.zope.org:/tmp/cvs-serv14386/src/zope/i18n/tests
Modified Files:
test_formats.py
Log Message:
- Got rid of (essentially) unused validateMapping, validateMappingAll,
ValidationErrorsAll and ConversionErrorsAll.
- Renamed zope.app.interfaces.forms to zope.app.interfaces.form
- Changed the way form input errors are handled. Now, *only*
validation errors and widget input errors are caught and displayed
on forms. These errors are about data entry problems. For these, it
never makes sense to show a traceback.
For Python programming errors, we want tracebacks, so it's important
to handle them differently, but letting the propigate and get logged
by the error reporting service.
This required updating the widget code to be more careful about
errors raised.
=== Zope3/src/zope/i18n/tests/test_formats.py 1.1 => 1.2 ===
--- Zope3/src/zope/i18n/tests/test_formats.py:1.1 Sun Jan 5 15:20:21 2003
+++ Zope3/src/zope/i18n/tests/test_formats.py Thu Jan 9 09:13:17 2003
@@ -200,108 +200,7 @@
# XXX The parser does not support timezones yet.
self.assertEqual(self.format.parse(
'Donnerstag, 2. Januar 2003 21:48 Uhr +100',
- "EEEE, d. MMMM yyyy H:mm' Uhr 'z"),
- datetime.datetime(2003, 01, 02, 21, 48))
-
- def testParseAMPMDateTime(self):
- self.assertEqual(
- self.format.parse('02.01.03 09:48 nachm.', 'dd.MM.yy hh:mm a'),
- datetime.datetime(2003, 01, 02, 21, 48))
-
- def testDateTimeParseError(self):
- self.assertRaises(DateTimeParseError,
- self.format.parse, '02.01.03 21:48', 'dd.MM.yyyy HH:mm')
-
- def testFormatSimpleDateTime(self):
- # German short
- self.assertEqual(
- self.format.format(datetime.datetime(2003, 01, 02, 21, 48),
- 'dd.MM.yy HH:mm'),
- '02.01.03 21:48')
-
- def testFormatRealDateTime(self):
- # German medium
- self.assertEqual(
- self.format.format(datetime.datetime(2003, 01, 02, 21, 48, 01),
- 'dd.MM.yyyy HH:mm:ss'),
- '02.01.2003 21:48:01')
-
- # German long
- # XXX The parser does not support timezones yet.
- self.assertEqual(self.format.format(
- datetime.datetime(2003, 01, 02, 21, 48, 01),
- 'd. MMMM yyyy HH:mm:ss z'),
- '2. Januar 2003 21:48:01 +000')
-
- # German full
- # XXX The parser does not support timezones yet.
- self.assertEqual(self.format.format(
- datetime.datetime(2003, 01, 02, 21, 48),
- "EEEE, d. MMMM yyyy H:mm' Uhr 'z"),
- 'Donnerstag, 2. Januar 2003 21:48 Uhr +000')
-
- def testFormatAMPMDateTime(self):
- self.assertEqual(self.format.format(
- datetime.datetime(2003, 01, 02, 21, 48),
- 'dd.MM.yy hh:mm a'),
- '02.01.03 09:48 nachm.')
-
-
-class TestNumberPatternParser(TestCase):
- """Extensive tests for the ICU-based-syntax number pattern parser."""
-
- def testParseSimpleIntegerPattern(self):
- self.assertEqual(
- parseNumberPattern('###0'),
- ( (None, '', None, '###0', '', '', None, '', None, 0),
- (None, '', None, '###0', '', '', None, '', None, 0)) )
-
- def testParseScientificIntegerPattern(self):
- self.assertEqual(
- parseNumberPattern('###0E#0'),
- ( (None, '', None, '###0', '', '#0', None, '', None, 0),
- (None, '', None, '###0', '', '#0', None, '', None, 0)) )
-
- def testParsePosNegAlternativeIntegerPattern(self):
- self.assertEqual(
- parseNumberPattern('###0;#0'),
- ( (None, '', None, '###0', '', '', None, '', None, 0),
- (None, '', None, '#0', '', '', None, '', None, 0)) )
-
- def testParsePrefixedIntegerPattern(self):
- self.assertEqual(
- parseNumberPattern('+###0'),
- ( (None, '+', None, '###0', '', '', None, '', None, 0),
- (None, '+', None, '###0', '', '', None, '', None, 0)) )
-
- def testParsePosNegIntegerPattern(self):
- self.assertEqual(
- parseNumberPattern('+###0;-###0'),
- ( (None, '+', None, '###0', '', '', None, '', None, 0),
- (None, '-', None, '###0', '', '', None, '', None, 0)) )
-
- def testParseScientificPosNegIntegerPattern(self):
- self.assertEqual(
- parseNumberPattern('+###0E0;-###0E#0'),
- ( (None, '+', None, '###0', '', '0', None, '', None, 0),
- (None, '-', None, '###0', '', '#0', None, '', None, 0)) )
-
- def testParseThousandSeparatorIntegerPattern(self):
- self.assertEqual(
- parseNumberPattern('#,##0'),
- ( (None, '', None, '###0', '', '', None, '', None, 1),
- (None, '', None, '###0', '', '', None, '', None, 1)) )
-
- def testParseSimpleDecimalPattern(self):
- self.assertEqual(
- parseNumberPattern('###0.00#'),
- ( (None, '', None, '###0', '00#', '', None, '', None, 0),
- (None, '', None, '###0', '00#', '', None, '', None, 0)) )
-
- def testParseScientificDecimalPattern(self):
- self.assertEqual(
- parseNumberPattern('###0.00#E#0'),
- ( (None, '', None, '###0', '00#', '#0', None, '', None, 0),
+ "E
(None, '', None, '###0', '00#', '#0', None, '', None, 0)) )
def testParsePosNegAlternativeFractionPattern(self):
@@ -665,95 +564,7 @@
'+23341')
self.assertEqual(self.format.format(41, '+#000;-#000'),
'+041')
- self.assertEqual(self.format.format(-23341, '+###0;-###0'),
- '-23341')
- self.assertEqual(self.format.format(-41, '+#000;-#000'),
- '-041')
-
- def testFormatPosNegScientificInteger(self):
- self.assertEqual(self.format.format(23341, '+0.00###E00;-0.00###E00'),
- '+2.3341E04')
- self.assertEqual(self.format.format(23341, '-0.00###E00;-0.00###E00'),
- '-2.3341E04')
-
- def testFormatThousandSeparatorInteger(self):
- self.assertEqual(self.format.format(23341, '+#,##0;-#,##0'),
- '+23,341')
- self.assertEqual(self.format.format(-23341, '+#,##0;-#,##0'),
- '-23,341')
- self.assertEqual(self.format.format(41, '+#0,000;-#0,000'),
- '+0,041')
- self.assertEqual(self.format.format(-41, '+#0,000;-#0,000'),
- '-0,041')
-
- def testFormatDecimal(self):
- self.assertEqual(self.format.format(23341.02357, '###0.0#'),
- '23341.02')
- self.assertEqual(self.format.format(23341.02357, '###0.000#'),
- '23341.0235')
- self.assertEqual(self.format.format(23341.02, '###0.000#'),
- '23341.020')
-
- def testFormatScientificDecimal(self):
- self.assertEqual(self.format.format(23341.02357, '0.00####E00'),
- '2.334102E04')
- self.assertEqual(self.format.format(23341.02, '0.0000000E000'),
- '2.3341020E004')
-
- def testFormatScientificDecimalSmallerOne(self):
- self.assertEqual(self.format.format(0.02357, '0.00####E00'),
- '2.357E-02')
- self.assertEqual(self.format.format(0.02, '0.0000E00'),
- '2.0000E-02')
-
- def testFormatPadding1WithoutPrefix(self):
- self.assertEqual(self.format.format(41, '* ##0;*_##0'),
- ' 41')
- self.assertEqual(self.format.format(-41, '* ##0;*_##0'),
- '_41')
-
- def testFormatPadding1WithPrefix(self):
- self.assertEqual(self.format.format(41, '* +##0;*_-##0'),
- ' +41')
- self.assertEqual(self.format.format(-41, '* +##0;*_-##0'),
- '_-41')
-
- def testFormatPadding1Scientific(self):
- self.assertEqual(self.format.format(41.02, '* 0.0####E0;*_0.0####E0'),
- ' 4.102E1')
- self.assertEqual(self.format.format(-41.02, '* 0.0####E0;*_0.0####E0'),
- '__4.102E1')
- self.assertEqual(self.format.format(41.02, '* +0.0###E0;*_-0.0###E0'),
- ' +4.102E1')
- self.assertEqual(self.format.format(-41.02, '* +0.0###E0;*_-0.0###E0'),
- '_-4.102E1')
-
- def testFormatPadding1Padding2WithPrefix(self):
- self.assertEqual(self.format.format(41, '* +* ###0;*_-*_###0'),
- ' + 41')
- self.assertEqual(self.format.format(-41, '* +* ###0;*_-*_###0'),
- '__-_41')
-
- def testFormatPadding3WithoutSufffix(self):
- self.assertEqual(self.format.format(41.02, '#0.0###* ;#0.0###*_'),
- '41.02 ')
- self.assertEqual(self.format.format(-41.02, '#0.0###* ;#0.0###*_'),
- '41.02__')
- def testFormatPadding3WithSufffix(self):
- self.assertEqual(self.format.format(41.02, '[#0.0###* ];(#0.0###*_)'),
- '[41.02 ]')
- self.assertEqual(self.format.format(-41.02, '[#0.0###* ];(#0.0###*_)'),
- '(41.02__)')
-
- def testFormatPadding3Scientific(self):
- self.assertEqual(self.format.format(41.02, '0.0##E0##* ;0.0##E0##*_'),
- '4.102E1 ')
- self.assertEqual(self.format.format(-41.02, '0.0##E0##* ;0.0##E0##*_'),
- '4.102E1__')
- self.assertEqual(self.format.format(41.02, '(0.0##E0##* );0.0E0'),
- '(4.102E1 )')
- self.assertEqual(self.format.format(-41.02, '0.0E0;[0.0##E0##*_]'),
'[4.102E1__]')
def testFormatPadding3Padding4WithSuffix(self):