Mercurial > babel > mirror
annotate babel/tests/numbers.py @ 588:acdb8f9c9ce6 trunk
disable doctests for babel.numbers in Python 2.4 due to changed Decimal repr output
author | fschwarz |
---|---|
date | Wed, 08 Aug 2012 12:23:20 +0000 |
parents | 964cd2ec6f94 |
children |
rev | line source |
---|---|
1 | 1 # -*- coding: utf-8 -*- |
2 # | |
530 | 3 # Copyright (C) 2007-2011 Edgewall Software |
1 | 4 # All rights reserved. |
5 # | |
6 # This software is licensed as described in the file COPYING, which | |
7 # you should have received as part of this distribution. The terms | |
8 # are also available at http://babel.edgewall.org/wiki/License. | |
9 # | |
10 # This software consists of voluntary contributions made by many | |
11 # individuals. For the exact contribution history, see the revision | |
12 # history and logs, available at http://babel.edgewall.org/log/. | |
13 | |
556 | 14 from decimal import Decimal |
1 | 15 import doctest |
16 import unittest | |
588
acdb8f9c9ce6
disable doctests for babel.numbers in Python 2.4 due to changed Decimal repr output
fschwarz
parents:
587
diff
changeset
|
17 import sys |
1 | 18 |
19 from babel import numbers | |
20 | |
50 | 21 |
22 class FormatDecimalTestCase(unittest.TestCase): | |
23 | |
218 | 24 def test_patterns(self): |
25 self.assertEqual(numbers.format_decimal(12345, '##0', | |
26 locale='en_US'), '12345') | |
27 self.assertEqual(numbers.format_decimal(6.5, '0.00', locale='sv'), | |
28 '6,50') | |
29 self.assertEqual(numbers.format_decimal(10.0**20, | |
30 '#.00', locale='en_US'), | |
31 '100000000000000000000.00') | |
576
e77dd06c40ef
fix formatting of fraction in format_decimal() if the input value is a float with more than 7 significant digits (#183)
fschwarz
parents:
557
diff
changeset
|
32 # regression test for #183, fraction digits were not correctly cutted |
e77dd06c40ef
fix formatting of fraction in format_decimal() if the input value is a float with more than 7 significant digits (#183)
fschwarz
parents:
557
diff
changeset
|
33 # if the input was a float value and the value had more than 7 |
e77dd06c40ef
fix formatting of fraction in format_decimal() if the input value is a float with more than 7 significant digits (#183)
fschwarz
parents:
557
diff
changeset
|
34 # significant digits |
e77dd06c40ef
fix formatting of fraction in format_decimal() if the input value is a float with more than 7 significant digits (#183)
fschwarz
parents:
557
diff
changeset
|
35 self.assertEqual(u'12,345,678.05', |
e77dd06c40ef
fix formatting of fraction in format_decimal() if the input value is a float with more than 7 significant digits (#183)
fschwarz
parents:
557
diff
changeset
|
36 numbers.format_decimal(12345678.051, '#,##0.00', |
e77dd06c40ef
fix formatting of fraction in format_decimal() if the input value is a float with more than 7 significant digits (#183)
fschwarz
parents:
557
diff
changeset
|
37 locale='en_US')) |
218 | 38 |
50 | 39 def test_subpatterns(self): |
40 self.assertEqual(numbers.format_decimal(-12345, '#,##0.##;-#', | |
41 locale='en_US'), '-12,345') | |
42 self.assertEqual(numbers.format_decimal(-12345, '#,##0.##;(#)', | |
43 locale='en_US'), '(12,345)') | |
44 | |
45 def test_default_rounding(self): | |
62
2df27f49c320
The order of extraction methods is now preserved (see #10).
cmlenz
parents:
50
diff
changeset
|
46 """ |
2df27f49c320
The order of extraction methods is now preserved (see #10).
cmlenz
parents:
50
diff
changeset
|
47 Testing Round-Half-Even (Banker's rounding) |
50 | 48 |
49 A '5' is rounded to the closest 'even' number | |
50 """ | |
51 self.assertEqual(numbers.format_decimal(5.5, '0', locale='sv'), '6') | |
52 self.assertEqual(numbers.format_decimal(6.5, '0', locale='sv'), '6') | |
218 | 53 self.assertEqual(numbers.format_decimal(6.5, '0', locale='sv'), '6') |
50 | 54 self.assertEqual(numbers.format_decimal(1.2325, locale='sv'), '1,232') |
55 self.assertEqual(numbers.format_decimal(1.2335, locale='sv'), '1,234') | |
56 | |
211
5125934e5f27
Added support for siginificant digits in number patterns.
jonas
parents:
62
diff
changeset
|
57 def test_significant_digits(self): |
5125934e5f27
Added support for siginificant digits in number patterns.
jonas
parents:
62
diff
changeset
|
58 """Test significant digits patterns""" |
5125934e5f27
Added support for siginificant digits in number patterns.
jonas
parents:
62
diff
changeset
|
59 self.assertEqual(numbers.format_decimal(123004, '@@',locale='en_US'), |
5125934e5f27
Added support for siginificant digits in number patterns.
jonas
parents:
62
diff
changeset
|
60 '120000') |
5125934e5f27
Added support for siginificant digits in number patterns.
jonas
parents:
62
diff
changeset
|
61 self.assertEqual(numbers.format_decimal(1.12, '@', locale='sv'), '1') |
5125934e5f27
Added support for siginificant digits in number patterns.
jonas
parents:
62
diff
changeset
|
62 self.assertEqual(numbers.format_decimal(1.1, '@@', locale='sv'), '1,1') |
5125934e5f27
Added support for siginificant digits in number patterns.
jonas
parents:
62
diff
changeset
|
63 self.assertEqual(numbers.format_decimal(1.1, '@@@@@##', locale='sv'), |
5125934e5f27
Added support for siginificant digits in number patterns.
jonas
parents:
62
diff
changeset
|
64 '1,1000') |
5125934e5f27
Added support for siginificant digits in number patterns.
jonas
parents:
62
diff
changeset
|
65 self.assertEqual(numbers.format_decimal(0.0001, '@@@', locale='sv'), |
5125934e5f27
Added support for siginificant digits in number patterns.
jonas
parents:
62
diff
changeset
|
66 '0,000100') |
5125934e5f27
Added support for siginificant digits in number patterns.
jonas
parents:
62
diff
changeset
|
67 self.assertEqual(numbers.format_decimal(0.0001234, '@@@', locale='sv'), |
5125934e5f27
Added support for siginificant digits in number patterns.
jonas
parents:
62
diff
changeset
|
68 '0,000123') |
5125934e5f27
Added support for siginificant digits in number patterns.
jonas
parents:
62
diff
changeset
|
69 self.assertEqual(numbers.format_decimal(0.0001234, '@@@#',locale='sv'), |
5125934e5f27
Added support for siginificant digits in number patterns.
jonas
parents:
62
diff
changeset
|
70 '0,0001234') |
5125934e5f27
Added support for siginificant digits in number patterns.
jonas
parents:
62
diff
changeset
|
71 self.assertEqual(numbers.format_decimal(0.0001234, '@@@#',locale='sv'), |
5125934e5f27
Added support for siginificant digits in number patterns.
jonas
parents:
62
diff
changeset
|
72 '0,0001234') |
5125934e5f27
Added support for siginificant digits in number patterns.
jonas
parents:
62
diff
changeset
|
73 self.assertEqual(numbers.format_decimal(0.12345, '@@@',locale='sv'), |
5125934e5f27
Added support for siginificant digits in number patterns.
jonas
parents:
62
diff
changeset
|
74 '0,123') |
5125934e5f27
Added support for siginificant digits in number patterns.
jonas
parents:
62
diff
changeset
|
75 self.assertEqual(numbers.format_decimal(3.14159, '@@##',locale='sv'), |
5125934e5f27
Added support for siginificant digits in number patterns.
jonas
parents:
62
diff
changeset
|
76 '3,142') |
5125934e5f27
Added support for siginificant digits in number patterns.
jonas
parents:
62
diff
changeset
|
77 self.assertEqual(numbers.format_decimal(1.23004, '@@##',locale='sv'), |
5125934e5f27
Added support for siginificant digits in number patterns.
jonas
parents:
62
diff
changeset
|
78 '1,23') |
5125934e5f27
Added support for siginificant digits in number patterns.
jonas
parents:
62
diff
changeset
|
79 self.assertEqual(numbers.format_decimal(1230.04, '@@,@@',locale='en_US'), |
5125934e5f27
Added support for siginificant digits in number patterns.
jonas
parents:
62
diff
changeset
|
80 '12,30') |
5125934e5f27
Added support for siginificant digits in number patterns.
jonas
parents:
62
diff
changeset
|
81 self.assertEqual(numbers.format_decimal(123.41, '@@##',locale='en_US'), |
5125934e5f27
Added support for siginificant digits in number patterns.
jonas
parents:
62
diff
changeset
|
82 '123.4') |
5125934e5f27
Added support for siginificant digits in number patterns.
jonas
parents:
62
diff
changeset
|
83 self.assertEqual(numbers.format_decimal(1, '@@',locale='en_US'), |
5125934e5f27
Added support for siginificant digits in number patterns.
jonas
parents:
62
diff
changeset
|
84 '1.0') |
5125934e5f27
Added support for siginificant digits in number patterns.
jonas
parents:
62
diff
changeset
|
85 self.assertEqual(numbers.format_decimal(0, '@',locale='en_US'), |
5125934e5f27
Added support for siginificant digits in number patterns.
jonas
parents:
62
diff
changeset
|
86 '0') |
5125934e5f27
Added support for siginificant digits in number patterns.
jonas
parents:
62
diff
changeset
|
87 self.assertEqual(numbers.format_decimal(0.1, '@',locale='en_US'), |
5125934e5f27
Added support for siginificant digits in number patterns.
jonas
parents:
62
diff
changeset
|
88 '0.1') |
5125934e5f27
Added support for siginificant digits in number patterns.
jonas
parents:
62
diff
changeset
|
89 self.assertEqual(numbers.format_decimal(0.1, '@#',locale='en_US'), |
5125934e5f27
Added support for siginificant digits in number patterns.
jonas
parents:
62
diff
changeset
|
90 '0.1') |
243
1e5787ab265b
Added initial support for scientific notation patterns.
jonas
parents:
218
diff
changeset
|
91 self.assertEqual(numbers.format_decimal(0.1, '@@', locale='en_US'), |
211
5125934e5f27
Added support for siginificant digits in number patterns.
jonas
parents:
62
diff
changeset
|
92 '0.10') |
218 | 93 |
556 | 94 def test_decimals(self): |
95 """Test significant digits patterns""" | |
96 self.assertEqual(numbers.format_decimal(Decimal('1.2345'), | |
97 '#.00', locale='en_US'), | |
98 '1.23') | |
99 self.assertEqual(numbers.format_decimal(Decimal('1.2345000'), | |
100 '#.00', locale='en_US'), | |
101 '1.23') | |
102 self.assertEqual(numbers.format_decimal(Decimal('1.2345000'), | |
103 '@@', locale='en_US'), | |
104 '1.2') | |
105 self.assertEqual(numbers.format_decimal(Decimal('12345678901234567890.12345'), | |
106 '#.00', locale='en_US'), | |
107 '12345678901234567890.12') | |
218 | 108 |
243
1e5787ab265b
Added initial support for scientific notation patterns.
jonas
parents:
218
diff
changeset
|
109 def test_scientific_notation(self): |
1e5787ab265b
Added initial support for scientific notation patterns.
jonas
parents:
218
diff
changeset
|
110 fmt = numbers.format_scientific(0.1, '#E0', locale='en_US') |
1e5787ab265b
Added initial support for scientific notation patterns.
jonas
parents:
218
diff
changeset
|
111 self.assertEqual(fmt, '1E-1') |
1e5787ab265b
Added initial support for scientific notation patterns.
jonas
parents:
218
diff
changeset
|
112 fmt = numbers.format_scientific(0.01, '#E0', locale='en_US') |
1e5787ab265b
Added initial support for scientific notation patterns.
jonas
parents:
218
diff
changeset
|
113 self.assertEqual(fmt, '1E-2') |
1e5787ab265b
Added initial support for scientific notation patterns.
jonas
parents:
218
diff
changeset
|
114 fmt = numbers.format_scientific(10, '#E0', locale='en_US') |
1e5787ab265b
Added initial support for scientific notation patterns.
jonas
parents:
218
diff
changeset
|
115 self.assertEqual(fmt, '1E1') |
1e5787ab265b
Added initial support for scientific notation patterns.
jonas
parents:
218
diff
changeset
|
116 fmt = numbers.format_scientific(1234, '0.###E0', locale='en_US') |
1e5787ab265b
Added initial support for scientific notation patterns.
jonas
parents:
218
diff
changeset
|
117 self.assertEqual(fmt, '1.234E3') |
1e5787ab265b
Added initial support for scientific notation patterns.
jonas
parents:
218
diff
changeset
|
118 fmt = numbers.format_scientific(1234, '0.#E0', locale='en_US') |
1e5787ab265b
Added initial support for scientific notation patterns.
jonas
parents:
218
diff
changeset
|
119 self.assertEqual(fmt, '1.2E3') |
1e5787ab265b
Added initial support for scientific notation patterns.
jonas
parents:
218
diff
changeset
|
120 # Exponent grouping |
1e5787ab265b
Added initial support for scientific notation patterns.
jonas
parents:
218
diff
changeset
|
121 fmt = numbers.format_scientific(12345, '##0.####E0', locale='en_US') |
1e5787ab265b
Added initial support for scientific notation patterns.
jonas
parents:
218
diff
changeset
|
122 self.assertEqual(fmt, '12.345E3') |
1e5787ab265b
Added initial support for scientific notation patterns.
jonas
parents:
218
diff
changeset
|
123 # Minimum number of int digits |
1e5787ab265b
Added initial support for scientific notation patterns.
jonas
parents:
218
diff
changeset
|
124 fmt = numbers.format_scientific(12345, '00.###E0', locale='en_US') |
1e5787ab265b
Added initial support for scientific notation patterns.
jonas
parents:
218
diff
changeset
|
125 self.assertEqual(fmt, '12.345E3') |
1e5787ab265b
Added initial support for scientific notation patterns.
jonas
parents:
218
diff
changeset
|
126 fmt = numbers.format_scientific(-12345.6, '00.###E0', locale='en_US') |
1e5787ab265b
Added initial support for scientific notation patterns.
jonas
parents:
218
diff
changeset
|
127 self.assertEqual(fmt, '-12.346E3') |
1e5787ab265b
Added initial support for scientific notation patterns.
jonas
parents:
218
diff
changeset
|
128 fmt = numbers.format_scientific(-0.01234, '00.###E0', locale='en_US') |
1e5787ab265b
Added initial support for scientific notation patterns.
jonas
parents:
218
diff
changeset
|
129 self.assertEqual(fmt, '-12.34E-3') |
1e5787ab265b
Added initial support for scientific notation patterns.
jonas
parents:
218
diff
changeset
|
130 # Custom pattern suffic |
1e5787ab265b
Added initial support for scientific notation patterns.
jonas
parents:
218
diff
changeset
|
131 fmt = numbers.format_scientific(123.45, '#.##E0 m/s', locale='en_US') |
1e5787ab265b
Added initial support for scientific notation patterns.
jonas
parents:
218
diff
changeset
|
132 self.assertEqual(fmt, '1.23E2 m/s') |
1e5787ab265b
Added initial support for scientific notation patterns.
jonas
parents:
218
diff
changeset
|
133 # Exponent patterns |
1e5787ab265b
Added initial support for scientific notation patterns.
jonas
parents:
218
diff
changeset
|
134 fmt = numbers.format_scientific(123.45, '#.##E00 m/s', locale='en_US') |
1e5787ab265b
Added initial support for scientific notation patterns.
jonas
parents:
218
diff
changeset
|
135 self.assertEqual(fmt, '1.23E02 m/s') |
1e5787ab265b
Added initial support for scientific notation patterns.
jonas
parents:
218
diff
changeset
|
136 fmt = numbers.format_scientific(0.012345, '#.##E00 m/s', locale='en_US') |
1e5787ab265b
Added initial support for scientific notation patterns.
jonas
parents:
218
diff
changeset
|
137 self.assertEqual(fmt, '1.23E-02 m/s') |
556 | 138 fmt = numbers.format_scientific(Decimal('12345'), '#.##E+00 m/s', |
139 locale='en_US') | |
140 self.assertEqual(fmt, '1.23E+04 m/s') | |
357 | 141 # 0 (see ticket #99) |
142 fmt = numbers.format_scientific(0, '#E0', locale='en_US') | |
143 self.assertEqual(fmt, '0E0') | |
580
ea413a4d754b
fix format_decimal() with small Decimal values (#214, patch from George Lund)
fschwarz
parents:
576
diff
changeset
|
144 |
ea413a4d754b
fix format_decimal() with small Decimal values (#214, patch from George Lund)
fschwarz
parents:
576
diff
changeset
|
145 def test_formatting_of_very_small_decimals(self): |
ea413a4d754b
fix format_decimal() with small Decimal values (#214, patch from George Lund)
fschwarz
parents:
576
diff
changeset
|
146 # previously formatting very small decimals could lead to a type error |
ea413a4d754b
fix format_decimal() with small Decimal values (#214, patch from George Lund)
fschwarz
parents:
576
diff
changeset
|
147 # because the Decimal->string conversion was too simple (see #214) |
ea413a4d754b
fix format_decimal() with small Decimal values (#214, patch from George Lund)
fschwarz
parents:
576
diff
changeset
|
148 number = Decimal("7E-7") |
ea413a4d754b
fix format_decimal() with small Decimal values (#214, patch from George Lund)
fschwarz
parents:
576
diff
changeset
|
149 fmt = numbers.format_decimal(number, format="@@@", locale='en_US') |
ea413a4d754b
fix format_decimal() with small Decimal values (#214, patch from George Lund)
fschwarz
parents:
576
diff
changeset
|
150 self.assertEqual('0.000000700', fmt) |
243
1e5787ab265b
Added initial support for scientific notation patterns.
jonas
parents:
218
diff
changeset
|
151 |
1e5787ab265b
Added initial support for scientific notation patterns.
jonas
parents:
218
diff
changeset
|
152 |
557
4e561e6411ba
Only use bankers round algorithm as a tie breaker if there are two nearest numbers, round as usual if there is only one nearest number (#267, patch by Martin)
fschwarz
parents:
556
diff
changeset
|
153 class BankersRoundTestCase(unittest.TestCase): |
4e561e6411ba
Only use bankers round algorithm as a tie breaker if there are two nearest numbers, round as usual if there is only one nearest number (#267, patch by Martin)
fschwarz
parents:
556
diff
changeset
|
154 def test_round_to_nearest_integer(self): |
4e561e6411ba
Only use bankers round algorithm as a tie breaker if there are two nearest numbers, round as usual if there is only one nearest number (#267, patch by Martin)
fschwarz
parents:
556
diff
changeset
|
155 self.assertEqual(1, numbers.bankersround(Decimal('0.5001'))) |
4e561e6411ba
Only use bankers round algorithm as a tie breaker if there are two nearest numbers, round as usual if there is only one nearest number (#267, patch by Martin)
fschwarz
parents:
556
diff
changeset
|
156 |
4e561e6411ba
Only use bankers round algorithm as a tie breaker if there are two nearest numbers, round as usual if there is only one nearest number (#267, patch by Martin)
fschwarz
parents:
556
diff
changeset
|
157 def test_round_to_even_for_two_nearest_integers(self): |
4e561e6411ba
Only use bankers round algorithm as a tie breaker if there are two nearest numbers, round as usual if there is only one nearest number (#267, patch by Martin)
fschwarz
parents:
556
diff
changeset
|
158 self.assertEqual(0, numbers.bankersround(Decimal('0.5'))) |
4e561e6411ba
Only use bankers round algorithm as a tie breaker if there are two nearest numbers, round as usual if there is only one nearest number (#267, patch by Martin)
fschwarz
parents:
556
diff
changeset
|
159 self.assertEqual(2, numbers.bankersround(Decimal('1.5'))) |
4e561e6411ba
Only use bankers round algorithm as a tie breaker if there are two nearest numbers, round as usual if there is only one nearest number (#267, patch by Martin)
fschwarz
parents:
556
diff
changeset
|
160 self.assertEqual(-2, numbers.bankersround(Decimal('-2.5'))) |
4e561e6411ba
Only use bankers round algorithm as a tie breaker if there are two nearest numbers, round as usual if there is only one nearest number (#267, patch by Martin)
fschwarz
parents:
556
diff
changeset
|
161 |
4e561e6411ba
Only use bankers round algorithm as a tie breaker if there are two nearest numbers, round as usual if there is only one nearest number (#267, patch by Martin)
fschwarz
parents:
556
diff
changeset
|
162 self.assertEqual(0, numbers.bankersround(Decimal('0.05'), ndigits=1)) |
4e561e6411ba
Only use bankers round algorithm as a tie breaker if there are two nearest numbers, round as usual if there is only one nearest number (#267, patch by Martin)
fschwarz
parents:
556
diff
changeset
|
163 self.assertEqual(Decimal('0.2'), numbers.bankersround(Decimal('0.15'), ndigits=1)) |
4e561e6411ba
Only use bankers round algorithm as a tie breaker if there are two nearest numbers, round as usual if there is only one nearest number (#267, patch by Martin)
fschwarz
parents:
556
diff
changeset
|
164 |
4e561e6411ba
Only use bankers round algorithm as a tie breaker if there are two nearest numbers, round as usual if there is only one nearest number (#267, patch by Martin)
fschwarz
parents:
556
diff
changeset
|
165 |
587
964cd2ec6f94
parse_decimal() now returns Decimals not floats, API change (#178)
fschwarz
parents:
580
diff
changeset
|
166 class NumberParsingTestCase(unittest.TestCase): |
964cd2ec6f94
parse_decimal() now returns Decimals not floats, API change (#178)
fschwarz
parents:
580
diff
changeset
|
167 def test_can_parse_decimals(self): |
964cd2ec6f94
parse_decimal() now returns Decimals not floats, API change (#178)
fschwarz
parents:
580
diff
changeset
|
168 self.assertEqual(Decimal('1099.98'), |
964cd2ec6f94
parse_decimal() now returns Decimals not floats, API change (#178)
fschwarz
parents:
580
diff
changeset
|
169 numbers.parse_decimal('1,099.98', locale='en_US')) |
964cd2ec6f94
parse_decimal() now returns Decimals not floats, API change (#178)
fschwarz
parents:
580
diff
changeset
|
170 self.assertEqual(Decimal('1099.98'), |
964cd2ec6f94
parse_decimal() now returns Decimals not floats, API change (#178)
fschwarz
parents:
580
diff
changeset
|
171 numbers.parse_decimal('1.099,98', locale='de')) |
964cd2ec6f94
parse_decimal() now returns Decimals not floats, API change (#178)
fschwarz
parents:
580
diff
changeset
|
172 self.assertRaises(numbers.NumberFormatError, |
964cd2ec6f94
parse_decimal() now returns Decimals not floats, API change (#178)
fschwarz
parents:
580
diff
changeset
|
173 lambda: numbers.parse_decimal('2,109,998', locale='de')) |
964cd2ec6f94
parse_decimal() now returns Decimals not floats, API change (#178)
fschwarz
parents:
580
diff
changeset
|
174 |
964cd2ec6f94
parse_decimal() now returns Decimals not floats, API change (#178)
fschwarz
parents:
580
diff
changeset
|
175 |
1 | 176 def suite(): |
177 suite = unittest.TestSuite() | |
588
acdb8f9c9ce6
disable doctests for babel.numbers in Python 2.4 due to changed Decimal repr output
fschwarz
parents:
587
diff
changeset
|
178 if sys.version_info >= (2, 5): |
acdb8f9c9ce6
disable doctests for babel.numbers in Python 2.4 due to changed Decimal repr output
fschwarz
parents:
587
diff
changeset
|
179 # repr(Decimal(...)) was changed 2.5 |
acdb8f9c9ce6
disable doctests for babel.numbers in Python 2.4 due to changed Decimal repr output
fschwarz
parents:
587
diff
changeset
|
180 # Python 2.4: Decimal("1") |
acdb8f9c9ce6
disable doctests for babel.numbers in Python 2.4 due to changed Decimal repr output
fschwarz
parents:
587
diff
changeset
|
181 # Python 2.5+: Decimal('1') |
acdb8f9c9ce6
disable doctests for babel.numbers in Python 2.4 due to changed Decimal repr output
fschwarz
parents:
587
diff
changeset
|
182 # as the actual functionality is tested by unit tests, I don't see a |
acdb8f9c9ce6
disable doctests for babel.numbers in Python 2.4 due to changed Decimal repr output
fschwarz
parents:
587
diff
changeset
|
183 # point in adding ugly workarounds in the doctests so just disable |
acdb8f9c9ce6
disable doctests for babel.numbers in Python 2.4 due to changed Decimal repr output
fschwarz
parents:
587
diff
changeset
|
184 # these doctests for 2.4 |
acdb8f9c9ce6
disable doctests for babel.numbers in Python 2.4 due to changed Decimal repr output
fschwarz
parents:
587
diff
changeset
|
185 suite.addTest(doctest.DocTestSuite(numbers)) |
50 | 186 suite.addTest(unittest.makeSuite(FormatDecimalTestCase)) |
557
4e561e6411ba
Only use bankers round algorithm as a tie breaker if there are two nearest numbers, round as usual if there is only one nearest number (#267, patch by Martin)
fschwarz
parents:
556
diff
changeset
|
187 suite.addTest(unittest.makeSuite(BankersRoundTestCase)) |
587
964cd2ec6f94
parse_decimal() now returns Decimals not floats, API change (#178)
fschwarz
parents:
580
diff
changeset
|
188 suite.addTest(unittest.makeSuite(NumberParsingTestCase)) |
1 | 189 return suite |
190 | |
191 if __name__ == '__main__': | |
192 unittest.main(defaultTest='suite') |