Benjamin Peterson | e549ead | 2009-03-28 21:42:05 +0000 | [diff] [blame] | 1 | from test.support import run_unittest, verbose |
Antoine Pitrou | 83d6a87 | 2008-07-25 21:45:08 +0000 | [diff] [blame] | 2 | import unittest |
Martin v. Löwis | 88ad12a | 2001-04-13 08:09:50 +0000 | [diff] [blame] | 3 | import locale |
Guido van Rossum | fc34986 | 2001-04-15 13:15:56 +0000 | [diff] [blame] | 4 | import sys |
Antoine Pitrou | 83d6a87 | 2008-07-25 21:45:08 +0000 | [diff] [blame] | 5 | import codecs |
Martin v. Löwis | 88ad12a | 2001-04-13 08:09:50 +0000 | [diff] [blame] | 6 | |
Antoine Pitrou | 13856ea | 2008-07-26 21:02:53 +0000 | [diff] [blame] | 7 | enUS_locale = None |
| 8 | |
| 9 | def get_enUS_locale(): |
| 10 | global enUS_locale |
Antoine Pitrou | 13856ea | 2008-07-26 21:02:53 +0000 | [diff] [blame] | 11 | if sys.platform.startswith("win"): |
| 12 | tlocs = ("En", "English") |
| 13 | else: |
Antoine Pitrou | 6a448d4 | 2009-10-19 19:43:09 +0000 | [diff] [blame] | 14 | tlocs = ("en_US.UTF-8", "en_US.ISO8859-1", "en_US.US-ASCII", "en_US") |
Antoine Pitrou | 13856ea | 2008-07-26 21:02:53 +0000 | [diff] [blame] | 15 | oldlocale = locale.setlocale(locale.LC_NUMERIC) |
| 16 | for tloc in tlocs: |
| 17 | try: |
| 18 | locale.setlocale(locale.LC_NUMERIC, tloc) |
| 19 | except locale.Error: |
| 20 | continue |
| 21 | break |
| 22 | else: |
Benjamin Peterson | e549ead | 2009-03-28 21:42:05 +0000 | [diff] [blame] | 23 | raise unittest.SkipTest( |
Antoine Pitrou | 13856ea | 2008-07-26 21:02:53 +0000 | [diff] [blame] | 24 | "Test locale not supported (tried %s)" % (', '.join(tlocs))) |
| 25 | enUS_locale = tloc |
| 26 | locale.setlocale(locale.LC_NUMERIC, oldlocale) |
| 27 | |
| 28 | |
Antoine Pitrou | 83d6a87 | 2008-07-25 21:45:08 +0000 | [diff] [blame] | 29 | class BaseLocalizedTest(unittest.TestCase): |
| 30 | # |
| 31 | # Base class for tests using a real locale |
| 32 | # |
Martin v. Löwis | 88ad12a | 2001-04-13 08:09:50 +0000 | [diff] [blame] | 33 | |
Antoine Pitrou | 83d6a87 | 2008-07-25 21:45:08 +0000 | [diff] [blame] | 34 | def setUp(self): |
Antoine Pitrou | 83d6a87 | 2008-07-25 21:45:08 +0000 | [diff] [blame] | 35 | self.oldlocale = locale.setlocale(self.locale_type) |
Antoine Pitrou | 13856ea | 2008-07-26 21:02:53 +0000 | [diff] [blame] | 36 | locale.setlocale(self.locale_type, enUS_locale) |
Martin v. Löwis | 88ad12a | 2001-04-13 08:09:50 +0000 | [diff] [blame] | 37 | if verbose: |
Antoine Pitrou | 13856ea | 2008-07-26 21:02:53 +0000 | [diff] [blame] | 38 | print("testing with \"%s\"..." % enUS_locale, end=' ') |
Martin v. Löwis | 88ad12a | 2001-04-13 08:09:50 +0000 | [diff] [blame] | 39 | |
Antoine Pitrou | 83d6a87 | 2008-07-25 21:45:08 +0000 | [diff] [blame] | 40 | def tearDown(self): |
| 41 | locale.setlocale(self.locale_type, self.oldlocale) |
Thomas Wouters | 477c8d5 | 2006-05-27 19:21:47 +0000 | [diff] [blame] | 42 | |
Thomas Wouters | 477c8d5 | 2006-05-27 19:21:47 +0000 | [diff] [blame] | 43 | |
Antoine Pitrou | 83d6a87 | 2008-07-25 21:45:08 +0000 | [diff] [blame] | 44 | class BaseCookedTest(unittest.TestCase): |
| 45 | # |
| 46 | # Base class for tests using cooked localeconv() values |
| 47 | # |
Georg Brandl | 3dbca81 | 2008-07-23 16:10:53 +0000 | [diff] [blame] | 48 | |
Antoine Pitrou | 83d6a87 | 2008-07-25 21:45:08 +0000 | [diff] [blame] | 49 | def setUp(self): |
| 50 | locale._override_localeconv = self.cooked_values |
| 51 | |
| 52 | def tearDown(self): |
| 53 | locale._override_localeconv = {} |
| 54 | |
| 55 | class CCookedTest(BaseCookedTest): |
| 56 | # A cooked "C" locale |
| 57 | |
| 58 | cooked_values = { |
| 59 | 'currency_symbol': '', |
| 60 | 'decimal_point': '.', |
| 61 | 'frac_digits': 127, |
| 62 | 'grouping': [], |
| 63 | 'int_curr_symbol': '', |
| 64 | 'int_frac_digits': 127, |
| 65 | 'mon_decimal_point': '', |
| 66 | 'mon_grouping': [], |
| 67 | 'mon_thousands_sep': '', |
| 68 | 'n_cs_precedes': 127, |
| 69 | 'n_sep_by_space': 127, |
| 70 | 'n_sign_posn': 127, |
| 71 | 'negative_sign': '', |
| 72 | 'p_cs_precedes': 127, |
| 73 | 'p_sep_by_space': 127, |
| 74 | 'p_sign_posn': 127, |
| 75 | 'positive_sign': '', |
| 76 | 'thousands_sep': '' |
| 77 | } |
| 78 | |
| 79 | class EnUSCookedTest(BaseCookedTest): |
| 80 | # A cooked "en_US" locale |
| 81 | |
| 82 | cooked_values = { |
| 83 | 'currency_symbol': '$', |
| 84 | 'decimal_point': '.', |
| 85 | 'frac_digits': 2, |
| 86 | 'grouping': [3, 3, 0], |
| 87 | 'int_curr_symbol': 'USD ', |
| 88 | 'int_frac_digits': 2, |
| 89 | 'mon_decimal_point': '.', |
| 90 | 'mon_grouping': [3, 3, 0], |
| 91 | 'mon_thousands_sep': ',', |
| 92 | 'n_cs_precedes': 1, |
| 93 | 'n_sep_by_space': 0, |
| 94 | 'n_sign_posn': 1, |
| 95 | 'negative_sign': '-', |
| 96 | 'p_cs_precedes': 1, |
| 97 | 'p_sep_by_space': 0, |
| 98 | 'p_sign_posn': 1, |
| 99 | 'positive_sign': '', |
| 100 | 'thousands_sep': ',' |
| 101 | } |
| 102 | |
| 103 | |
Antoine Pitrou | 350370c | 2009-03-14 00:13:13 +0000 | [diff] [blame] | 104 | class FrFRCookedTest(BaseCookedTest): |
| 105 | # A cooked "fr_FR" locale with a space character as decimal separator |
| 106 | # and a non-ASCII currency symbol. |
| 107 | |
| 108 | cooked_values = { |
| 109 | 'currency_symbol': '\u20ac', |
| 110 | 'decimal_point': ',', |
| 111 | 'frac_digits': 2, |
| 112 | 'grouping': [3, 3, 0], |
| 113 | 'int_curr_symbol': 'EUR ', |
| 114 | 'int_frac_digits': 2, |
| 115 | 'mon_decimal_point': ',', |
| 116 | 'mon_grouping': [3, 3, 0], |
| 117 | 'mon_thousands_sep': ' ', |
| 118 | 'n_cs_precedes': 0, |
| 119 | 'n_sep_by_space': 1, |
| 120 | 'n_sign_posn': 1, |
| 121 | 'negative_sign': '-', |
| 122 | 'p_cs_precedes': 0, |
| 123 | 'p_sep_by_space': 1, |
| 124 | 'p_sign_posn': 1, |
| 125 | 'positive_sign': '', |
| 126 | 'thousands_sep': ' ' |
| 127 | } |
| 128 | |
| 129 | |
Antoine Pitrou | 83d6a87 | 2008-07-25 21:45:08 +0000 | [diff] [blame] | 130 | class BaseFormattingTest(object): |
| 131 | # |
| 132 | # Utility functions for formatting tests |
| 133 | # |
| 134 | |
| 135 | def _test_formatfunc(self, format, value, out, func, **format_opts): |
| 136 | self.assertEqual( |
| 137 | func(format, value, **format_opts), out) |
| 138 | |
| 139 | def _test_format(self, format, value, out, **format_opts): |
| 140 | self._test_formatfunc(format, value, out, |
| 141 | func=locale.format, **format_opts) |
| 142 | |
| 143 | def _test_format_string(self, format, value, out, **format_opts): |
| 144 | self._test_formatfunc(format, value, out, |
| 145 | func=locale.format_string, **format_opts) |
| 146 | |
| 147 | def _test_currency(self, value, out, **format_opts): |
| 148 | self.assertEqual(locale.currency(value, **format_opts), out) |
| 149 | |
| 150 | |
| 151 | class EnUSNumberFormatting(BaseFormattingTest): |
Antoine Pitrou | 13856ea | 2008-07-26 21:02:53 +0000 | [diff] [blame] | 152 | # XXX there is a grouping + padding bug when the thousands separator |
| 153 | # is empty but the grouping array contains values (e.g. Solaris 10) |
Antoine Pitrou | 83d6a87 | 2008-07-25 21:45:08 +0000 | [diff] [blame] | 154 | |
| 155 | def setUp(self): |
Antoine Pitrou | 83d6a87 | 2008-07-25 21:45:08 +0000 | [diff] [blame] | 156 | self.sep = locale.localeconv()['thousands_sep'] |
| 157 | |
| 158 | def test_grouping(self): |
| 159 | self._test_format("%f", 1024, grouping=1, out='1%s024.000000' % self.sep) |
| 160 | self._test_format("%f", 102, grouping=1, out='102.000000') |
| 161 | self._test_format("%f", -42, grouping=1, out='-42.000000') |
| 162 | self._test_format("%+f", -42, grouping=1, out='-42.000000') |
| 163 | |
| 164 | def test_grouping_and_padding(self): |
| 165 | self._test_format("%20.f", -42, grouping=1, out='-42'.rjust(20)) |
Antoine Pitrou | 13856ea | 2008-07-26 21:02:53 +0000 | [diff] [blame] | 166 | if self.sep: |
| 167 | self._test_format("%+10.f", -4200, grouping=1, |
| 168 | out=('-4%s200' % self.sep).rjust(10)) |
| 169 | self._test_format("%-10.f", -4200, grouping=1, |
| 170 | out=('-4%s200' % self.sep).ljust(10)) |
Antoine Pitrou | 83d6a87 | 2008-07-25 21:45:08 +0000 | [diff] [blame] | 171 | |
| 172 | def test_integer_grouping(self): |
| 173 | self._test_format("%d", 4200, grouping=True, out='4%s200' % self.sep) |
| 174 | self._test_format("%+d", 4200, grouping=True, out='+4%s200' % self.sep) |
| 175 | self._test_format("%+d", -4200, grouping=True, out='-4%s200' % self.sep) |
| 176 | |
Antoine Pitrou | 350370c | 2009-03-14 00:13:13 +0000 | [diff] [blame] | 177 | def test_integer_grouping_and_padding(self): |
| 178 | self._test_format("%10d", 4200, grouping=True, |
| 179 | out=('4%s200' % self.sep).rjust(10)) |
| 180 | self._test_format("%-10d", -4200, grouping=True, |
| 181 | out=('-4%s200' % self.sep).ljust(10)) |
| 182 | |
Antoine Pitrou | 83d6a87 | 2008-07-25 21:45:08 +0000 | [diff] [blame] | 183 | def test_simple(self): |
| 184 | self._test_format("%f", 1024, grouping=0, out='1024.000000') |
| 185 | self._test_format("%f", 102, grouping=0, out='102.000000') |
| 186 | self._test_format("%f", -42, grouping=0, out='-42.000000') |
| 187 | self._test_format("%+f", -42, grouping=0, out='-42.000000') |
| 188 | |
| 189 | def test_padding(self): |
| 190 | self._test_format("%20.f", -42, grouping=0, out='-42'.rjust(20)) |
| 191 | self._test_format("%+10.f", -4200, grouping=0, out='-4200'.rjust(10)) |
| 192 | self._test_format("%-10.f", 4200, grouping=0, out='4200'.ljust(10)) |
| 193 | |
| 194 | def test_complex_formatting(self): |
| 195 | # Spaces in formatting string |
| 196 | self._test_format_string("One million is %i", 1000000, grouping=1, |
| 197 | out='One million is 1%s000%s000' % (self.sep, self.sep)) |
| 198 | self._test_format_string("One million is %i", 1000000, grouping=1, |
| 199 | out='One million is 1%s000%s000' % (self.sep, self.sep)) |
| 200 | # Dots in formatting string |
| 201 | self._test_format_string(".%f.", 1000.0, out='.1000.000000.') |
| 202 | # Padding |
Antoine Pitrou | 13856ea | 2008-07-26 21:02:53 +0000 | [diff] [blame] | 203 | if self.sep: |
| 204 | self._test_format_string("--> %10.2f", 4200, grouping=1, |
| 205 | out='--> ' + ('4%s200.00' % self.sep).rjust(10)) |
Antoine Pitrou | 83d6a87 | 2008-07-25 21:45:08 +0000 | [diff] [blame] | 206 | # Asterisk formats |
| 207 | self._test_format_string("%10.*f", (2, 1000), grouping=0, |
| 208 | out='1000.00'.rjust(10)) |
Antoine Pitrou | 13856ea | 2008-07-26 21:02:53 +0000 | [diff] [blame] | 209 | if self.sep: |
| 210 | self._test_format_string("%*.*f", (10, 2, 1000), grouping=1, |
| 211 | out=('1%s000.00' % self.sep).rjust(10)) |
Antoine Pitrou | 83d6a87 | 2008-07-25 21:45:08 +0000 | [diff] [blame] | 212 | # Test more-in-one |
Antoine Pitrou | 13856ea | 2008-07-26 21:02:53 +0000 | [diff] [blame] | 213 | if self.sep: |
| 214 | self._test_format_string("int %i float %.2f str %s", |
| 215 | (1000, 1000.0, 'str'), grouping=1, |
| 216 | out='int 1%s000 float 1%s000.00 str str' % |
| 217 | (self.sep, self.sep)) |
Antoine Pitrou | 83d6a87 | 2008-07-25 21:45:08 +0000 | [diff] [blame] | 218 | |
| 219 | |
R. David Murray | e59482e | 2009-04-01 03:42:00 +0000 | [diff] [blame] | 220 | class TestFormatPatternArg(unittest.TestCase): |
| 221 | # Test handling of pattern argument of format |
| 222 | |
| 223 | def test_onlyOnePattern(self): |
| 224 | # Issue 2522: accept exactly one % pattern, and no extra chars. |
| 225 | self.assertRaises(ValueError, locale.format, "%f\n", 'foo') |
| 226 | self.assertRaises(ValueError, locale.format, "%f\r", 'foo') |
| 227 | self.assertRaises(ValueError, locale.format, "%f\r\n", 'foo') |
| 228 | self.assertRaises(ValueError, locale.format, " %f", 'foo') |
| 229 | self.assertRaises(ValueError, locale.format, "%fg", 'foo') |
| 230 | self.assertRaises(ValueError, locale.format, "%^g", 'foo') |
| 231 | |
| 232 | |
Antoine Pitrou | 83d6a87 | 2008-07-25 21:45:08 +0000 | [diff] [blame] | 233 | class TestNumberFormatting(BaseLocalizedTest, EnUSNumberFormatting): |
| 234 | # Test number formatting with a real English locale. |
| 235 | |
| 236 | locale_type = locale.LC_NUMERIC |
| 237 | |
| 238 | def setUp(self): |
| 239 | BaseLocalizedTest.setUp(self) |
| 240 | EnUSNumberFormatting.setUp(self) |
| 241 | |
| 242 | |
| 243 | class TestEnUSNumberFormatting(EnUSCookedTest, EnUSNumberFormatting): |
| 244 | # Test number formatting with a cooked "en_US" locale. |
| 245 | |
| 246 | def setUp(self): |
| 247 | EnUSCookedTest.setUp(self) |
| 248 | EnUSNumberFormatting.setUp(self) |
| 249 | |
| 250 | def test_currency(self): |
| 251 | self._test_currency(50000, "$50000.00") |
| 252 | self._test_currency(50000, "$50,000.00", grouping=True) |
| 253 | self._test_currency(50000, "USD 50,000.00", |
| 254 | grouping=True, international=True) |
| 255 | |
| 256 | |
| 257 | class TestCNumberFormatting(CCookedTest, BaseFormattingTest): |
| 258 | # Test number formatting with a cooked "C" locale. |
| 259 | |
| 260 | def test_grouping(self): |
| 261 | self._test_format("%.2f", 12345.67, grouping=True, out='12345.67') |
| 262 | |
| 263 | def test_grouping_and_padding(self): |
| 264 | self._test_format("%9.2f", 12345.67, grouping=True, out=' 12345.67') |
| 265 | |
| 266 | |
Antoine Pitrou | 350370c | 2009-03-14 00:13:13 +0000 | [diff] [blame] | 267 | class TestFrFRNumberFormatting(FrFRCookedTest, BaseFormattingTest): |
| 268 | # Test number formatting with a cooked "fr_FR" locale. |
| 269 | |
| 270 | def test_decimal_point(self): |
| 271 | self._test_format("%.2f", 12345.67, out='12345,67') |
| 272 | |
| 273 | def test_grouping(self): |
| 274 | self._test_format("%.2f", 345.67, grouping=True, out='345,67') |
| 275 | self._test_format("%.2f", 12345.67, grouping=True, out='12 345,67') |
| 276 | |
| 277 | def test_grouping_and_padding(self): |
| 278 | self._test_format("%6.2f", 345.67, grouping=True, out='345,67') |
| 279 | self._test_format("%7.2f", 345.67, grouping=True, out=' 345,67') |
| 280 | self._test_format("%8.2f", 12345.67, grouping=True, out='12 345,67') |
| 281 | self._test_format("%9.2f", 12345.67, grouping=True, out='12 345,67') |
| 282 | self._test_format("%10.2f", 12345.67, grouping=True, out=' 12 345,67') |
| 283 | self._test_format("%-6.2f", 345.67, grouping=True, out='345,67') |
| 284 | self._test_format("%-7.2f", 345.67, grouping=True, out='345,67 ') |
| 285 | self._test_format("%-8.2f", 12345.67, grouping=True, out='12 345,67') |
| 286 | self._test_format("%-9.2f", 12345.67, grouping=True, out='12 345,67') |
| 287 | self._test_format("%-10.2f", 12345.67, grouping=True, out='12 345,67 ') |
| 288 | |
| 289 | def test_integer_grouping(self): |
| 290 | self._test_format("%d", 200, grouping=True, out='200') |
| 291 | self._test_format("%d", 4200, grouping=True, out='4 200') |
| 292 | |
| 293 | def test_integer_grouping_and_padding(self): |
| 294 | self._test_format("%4d", 4200, grouping=True, out='4 200') |
| 295 | self._test_format("%5d", 4200, grouping=True, out='4 200') |
| 296 | self._test_format("%10d", 4200, grouping=True, out='4 200'.rjust(10)) |
| 297 | self._test_format("%-4d", 4200, grouping=True, out='4 200') |
| 298 | self._test_format("%-5d", 4200, grouping=True, out='4 200') |
| 299 | self._test_format("%-10d", 4200, grouping=True, out='4 200'.ljust(10)) |
| 300 | |
| 301 | def test_currency(self): |
| 302 | euro = '\u20ac' |
| 303 | self._test_currency(50000, "50000,00 " + euro) |
| 304 | self._test_currency(50000, "50 000,00 " + euro, grouping=True) |
| 305 | # XXX is the trailing space a bug? |
| 306 | self._test_currency(50000, "50 000,00 EUR ", |
| 307 | grouping=True, international=True) |
| 308 | |
| 309 | |
Antoine Pitrou | 6a448d4 | 2009-10-19 19:43:09 +0000 | [diff] [blame] | 310 | class TestCollation(unittest.TestCase): |
| 311 | # Test string collation functions |
| 312 | |
| 313 | def test_strcoll(self): |
| 314 | self.assertLess(locale.strcoll('a', 'b'), 0) |
| 315 | self.assertEqual(locale.strcoll('a', 'a'), 0) |
| 316 | self.assertGreater(locale.strcoll('b', 'a'), 0) |
| 317 | |
| 318 | def test_strxfrm(self): |
| 319 | self.assertLess(locale.strxfrm('a'), locale.strxfrm('b')) |
| 320 | |
| 321 | |
| 322 | class TestEnUSCollation(BaseLocalizedTest, TestCollation): |
| 323 | # Test string collation functions with a real English locale |
| 324 | |
| 325 | locale_type = locale.LC_ALL |
| 326 | |
| 327 | def setUp(self): |
| 328 | BaseLocalizedTest.setUp(self) |
| 329 | enc = codecs.lookup(locale.getpreferredencoding(False) or 'ascii').name |
| 330 | if enc not in ('utf-8', 'iso8859-1', 'cp1252'): |
| 331 | raise unittest.SkipTest('encoding not suitable') |
| 332 | if enc != 'iso8859-1' and (sys.platform == 'darwin' or |
| 333 | sys.platform.startswith('freebsd')): |
| 334 | raise unittest.SkipTest('wcscoll/wcsxfrm have known bugs') |
| 335 | |
| 336 | def test_strcoll_with_diacritic(self): |
| 337 | self.assertLess(locale.strcoll('à', 'b'), 0) |
| 338 | |
| 339 | def test_strxfrm_with_diacritic(self): |
| 340 | self.assertLess(locale.strxfrm('à'), locale.strxfrm('b')) |
| 341 | |
| 342 | |
Antoine Pitrou | 83d6a87 | 2008-07-25 21:45:08 +0000 | [diff] [blame] | 343 | class TestMiscellaneous(unittest.TestCase): |
| 344 | def test_getpreferredencoding(self): |
| 345 | # Invoke getpreferredencoding to make sure it does not cause exceptions. |
| 346 | enc = locale.getpreferredencoding() |
| 347 | if enc: |
| 348 | # If encoding non-empty, make sure it is valid |
| 349 | codecs.lookup(enc) |
| 350 | |
Antoine Pitrou | 6a448d4 | 2009-10-19 19:43:09 +0000 | [diff] [blame] | 351 | def test_strcoll_3303(self): |
| 352 | # test crasher from bug #3303 |
| 353 | self.assertRaises(TypeError, locale.strcoll, "a", None) |
| 354 | self.assertRaises(TypeError, locale.strcoll, b"a", None) |
Antoine Pitrou | 83d6a87 | 2008-07-25 21:45:08 +0000 | [diff] [blame] | 355 | |
Amaury Forgeot d'Arc | 64f3ca4 | 2009-12-01 21:59:18 +0000 | [diff] [blame] | 356 | def test_setlocale_category(self): |
| 357 | locale.setlocale(locale.LC_ALL) |
| 358 | locale.setlocale(locale.LC_TIME) |
| 359 | locale.setlocale(locale.LC_CTYPE) |
| 360 | locale.setlocale(locale.LC_COLLATE) |
| 361 | locale.setlocale(locale.LC_MONETARY) |
| 362 | locale.setlocale(locale.LC_NUMERIC) |
| 363 | |
| 364 | # crasher from bug #7419 |
| 365 | self.assertRaises(locale.Error, locale.setlocale, 12345) |
| 366 | |
Antoine Pitrou | 83d6a87 | 2008-07-25 21:45:08 +0000 | [diff] [blame] | 367 | |
| 368 | def test_main(): |
Antoine Pitrou | 13856ea | 2008-07-26 21:02:53 +0000 | [diff] [blame] | 369 | tests = [ |
| 370 | TestMiscellaneous, |
R. David Murray | e59482e | 2009-04-01 03:42:00 +0000 | [diff] [blame] | 371 | TestFormatPatternArg, |
Antoine Pitrou | 13856ea | 2008-07-26 21:02:53 +0000 | [diff] [blame] | 372 | TestEnUSNumberFormatting, |
Antoine Pitrou | 350370c | 2009-03-14 00:13:13 +0000 | [diff] [blame] | 373 | TestCNumberFormatting, |
| 374 | TestFrFRNumberFormatting, |
Antoine Pitrou | 6a448d4 | 2009-10-19 19:43:09 +0000 | [diff] [blame] | 375 | TestCollation |
Antoine Pitrou | 13856ea | 2008-07-26 21:02:53 +0000 | [diff] [blame] | 376 | ] |
Benjamin Peterson | e549ead | 2009-03-28 21:42:05 +0000 | [diff] [blame] | 377 | # SkipTest can't be raised inside unittests, handle it manually instead |
Antoine Pitrou | 13856ea | 2008-07-26 21:02:53 +0000 | [diff] [blame] | 378 | try: |
| 379 | get_enUS_locale() |
Benjamin Peterson | e549ead | 2009-03-28 21:42:05 +0000 | [diff] [blame] | 380 | except unittest.SkipTest as e: |
Antoine Pitrou | 13856ea | 2008-07-26 21:02:53 +0000 | [diff] [blame] | 381 | if verbose: |
| 382 | print("Some tests will be disabled: %s" % e) |
| 383 | else: |
Antoine Pitrou | 6a448d4 | 2009-10-19 19:43:09 +0000 | [diff] [blame] | 384 | tests += [TestNumberFormatting, TestEnUSCollation] |
Antoine Pitrou | 13856ea | 2008-07-26 21:02:53 +0000 | [diff] [blame] | 385 | run_unittest(*tests) |
Antoine Pitrou | 83d6a87 | 2008-07-25 21:45:08 +0000 | [diff] [blame] | 386 | |
| 387 | if __name__ == '__main__': |
| 388 | test_main() |