Antoine Pitrou | 524f413 | 2008-07-26 10:29:43 +0000 | [diff] [blame] | 1 | from test.test_support import run_unittest, verbose, TestSkipped |
Antoine Pitrou | ba54eda | 2008-07-25 20:40:19 +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 | ba54eda | 2008-07-25 20:40:19 +0000 | [diff] [blame] | 5 | import codecs |
Martin v. Löwis | 88ad12a | 2001-04-13 08:09:50 +0000 | [diff] [blame] | 6 | |
Martin v. Löwis | 88ad12a | 2001-04-13 08:09:50 +0000 | [diff] [blame] | 7 | |
Antoine Pitrou | 524f413 | 2008-07-26 10:29:43 +0000 | [diff] [blame] | 8 | enUS_locale = None |
| 9 | |
| 10 | def get_enUS_locale(): |
| 11 | global enUS_locale |
| 12 | if sys.platform == 'darwin': |
Ronald Oussoren | 0746619 | 2010-04-18 14:34:22 +0000 | [diff] [blame] | 13 | import os |
| 14 | tlocs = ("en_US.UTF-8", "en_US.ISO8859-1", "en_US") |
| 15 | if int(os.uname()[2].split('.')[0]) < 10: |
| 16 | # The locale test work fine on OSX 10.6, I (ronaldoussoren) |
| 17 | # haven't had time yet to verify if tests work on OSX 10.5 |
| 18 | # (10.4 is known to be bad) |
Victor Stinner | 797a49c | 2010-04-19 12:20:14 +0000 | [diff] [blame] | 19 | raise TestSkipped("Locale support on MacOSX is minimal") |
Antoine Pitrou | 524f413 | 2008-07-26 10:29:43 +0000 | [diff] [blame] | 20 | if sys.platform.startswith("win"): |
| 21 | tlocs = ("En", "English") |
| 22 | else: |
| 23 | tlocs = ("en_US.UTF-8", "en_US.US-ASCII", "en_US") |
| 24 | oldlocale = locale.setlocale(locale.LC_NUMERIC) |
| 25 | for tloc in tlocs: |
| 26 | try: |
| 27 | locale.setlocale(locale.LC_NUMERIC, tloc) |
| 28 | except locale.Error: |
| 29 | continue |
| 30 | break |
| 31 | else: |
| 32 | raise TestSkipped( |
| 33 | "Test locale not supported (tried %s)" % (', '.join(tlocs))) |
| 34 | enUS_locale = tloc |
| 35 | locale.setlocale(locale.LC_NUMERIC, oldlocale) |
| 36 | |
| 37 | |
Antoine Pitrou | ba54eda | 2008-07-25 20:40:19 +0000 | [diff] [blame] | 38 | class BaseLocalizedTest(unittest.TestCase): |
| 39 | # |
| 40 | # Base class for tests using a real locale |
| 41 | # |
Guido van Rossum | fc34986 | 2001-04-15 13:15:56 +0000 | [diff] [blame] | 42 | |
Antoine Pitrou | ba54eda | 2008-07-25 20:40:19 +0000 | [diff] [blame] | 43 | def setUp(self): |
Antoine Pitrou | ba54eda | 2008-07-25 20:40:19 +0000 | [diff] [blame] | 44 | self.oldlocale = locale.setlocale(self.locale_type) |
Antoine Pitrou | 524f413 | 2008-07-26 10:29:43 +0000 | [diff] [blame] | 45 | locale.setlocale(self.locale_type, enUS_locale) |
Martin v. Löwis | 88ad12a | 2001-04-13 08:09:50 +0000 | [diff] [blame] | 46 | if verbose: |
Antoine Pitrou | 524f413 | 2008-07-26 10:29:43 +0000 | [diff] [blame] | 47 | print "testing with \"%s\"..." % enUS_locale, |
Martin v. Löwis | 88ad12a | 2001-04-13 08:09:50 +0000 | [diff] [blame] | 48 | |
Antoine Pitrou | ba54eda | 2008-07-25 20:40:19 +0000 | [diff] [blame] | 49 | def tearDown(self): |
| 50 | locale.setlocale(self.locale_type, self.oldlocale) |
Hye-Shik Chang | b5047fd | 2004-08-04 06:33:51 +0000 | [diff] [blame] | 51 | |
| 52 | |
Antoine Pitrou | ba54eda | 2008-07-25 20:40:19 +0000 | [diff] [blame] | 53 | class BaseCookedTest(unittest.TestCase): |
| 54 | # |
| 55 | # Base class for tests using cooked localeconv() values |
| 56 | # |
Hye-Shik Chang | b5047fd | 2004-08-04 06:33:51 +0000 | [diff] [blame] | 57 | |
Antoine Pitrou | ba54eda | 2008-07-25 20:40:19 +0000 | [diff] [blame] | 58 | def setUp(self): |
| 59 | locale._override_localeconv = self.cooked_values |
Georg Brandl | 278fc50 | 2008-07-19 12:46:12 +0000 | [diff] [blame] | 60 | |
Antoine Pitrou | ba54eda | 2008-07-25 20:40:19 +0000 | [diff] [blame] | 61 | def tearDown(self): |
| 62 | locale._override_localeconv = {} |
| 63 | |
| 64 | |
| 65 | class CCookedTest(BaseCookedTest): |
| 66 | # A cooked "C" locale |
| 67 | |
| 68 | cooked_values = { |
| 69 | 'currency_symbol': '', |
| 70 | 'decimal_point': '.', |
| 71 | 'frac_digits': 127, |
| 72 | 'grouping': [], |
| 73 | 'int_curr_symbol': '', |
| 74 | 'int_frac_digits': 127, |
| 75 | 'mon_decimal_point': '', |
| 76 | 'mon_grouping': [], |
| 77 | 'mon_thousands_sep': '', |
| 78 | 'n_cs_precedes': 127, |
| 79 | 'n_sep_by_space': 127, |
| 80 | 'n_sign_posn': 127, |
| 81 | 'negative_sign': '', |
| 82 | 'p_cs_precedes': 127, |
| 83 | 'p_sep_by_space': 127, |
| 84 | 'p_sign_posn': 127, |
| 85 | 'positive_sign': '', |
| 86 | 'thousands_sep': '' |
| 87 | } |
| 88 | |
| 89 | class EnUSCookedTest(BaseCookedTest): |
| 90 | # A cooked "en_US" locale |
| 91 | |
| 92 | cooked_values = { |
| 93 | 'currency_symbol': '$', |
| 94 | 'decimal_point': '.', |
| 95 | 'frac_digits': 2, |
| 96 | 'grouping': [3, 3, 0], |
| 97 | 'int_curr_symbol': 'USD ', |
| 98 | 'int_frac_digits': 2, |
| 99 | 'mon_decimal_point': '.', |
| 100 | 'mon_grouping': [3, 3, 0], |
| 101 | 'mon_thousands_sep': ',', |
| 102 | 'n_cs_precedes': 1, |
| 103 | 'n_sep_by_space': 0, |
| 104 | 'n_sign_posn': 1, |
| 105 | 'negative_sign': '-', |
| 106 | 'p_cs_precedes': 1, |
| 107 | 'p_sep_by_space': 0, |
| 108 | 'p_sign_posn': 1, |
| 109 | 'positive_sign': '', |
| 110 | 'thousands_sep': ',' |
| 111 | } |
| 112 | |
| 113 | |
Antoine Pitrou | a099d14 | 2009-03-14 00:13:36 +0000 | [diff] [blame] | 114 | class FrFRCookedTest(BaseCookedTest): |
| 115 | # A cooked "fr_FR" locale with a space character as decimal separator |
| 116 | # and a non-ASCII currency symbol. |
| 117 | |
| 118 | cooked_values = { |
| 119 | 'currency_symbol': '\xe2\x82\xac', |
| 120 | 'decimal_point': ',', |
| 121 | 'frac_digits': 2, |
| 122 | 'grouping': [3, 3, 0], |
| 123 | 'int_curr_symbol': 'EUR ', |
| 124 | 'int_frac_digits': 2, |
| 125 | 'mon_decimal_point': ',', |
| 126 | 'mon_grouping': [3, 3, 0], |
| 127 | 'mon_thousands_sep': ' ', |
| 128 | 'n_cs_precedes': 0, |
| 129 | 'n_sep_by_space': 1, |
| 130 | 'n_sign_posn': 1, |
| 131 | 'negative_sign': '-', |
| 132 | 'p_cs_precedes': 0, |
| 133 | 'p_sep_by_space': 1, |
| 134 | 'p_sign_posn': 1, |
| 135 | 'positive_sign': '', |
| 136 | 'thousands_sep': ' ' |
| 137 | } |
| 138 | |
| 139 | |
Antoine Pitrou | ba54eda | 2008-07-25 20:40:19 +0000 | [diff] [blame] | 140 | class BaseFormattingTest(object): |
| 141 | # |
| 142 | # Utility functions for formatting tests |
| 143 | # |
| 144 | |
| 145 | def _test_formatfunc(self, format, value, out, func, **format_opts): |
| 146 | self.assertEqual( |
| 147 | func(format, value, **format_opts), out) |
| 148 | |
| 149 | def _test_format(self, format, value, out, **format_opts): |
| 150 | self._test_formatfunc(format, value, out, |
| 151 | func=locale.format, **format_opts) |
| 152 | |
| 153 | def _test_format_string(self, format, value, out, **format_opts): |
| 154 | self._test_formatfunc(format, value, out, |
| 155 | func=locale.format_string, **format_opts) |
| 156 | |
| 157 | def _test_currency(self, value, out, **format_opts): |
| 158 | self.assertEqual(locale.currency(value, **format_opts), out) |
| 159 | |
| 160 | |
| 161 | class EnUSNumberFormatting(BaseFormattingTest): |
Antoine Pitrou | 36897e1 | 2008-07-26 13:49:13 +0000 | [diff] [blame] | 162 | # XXX there is a grouping + padding bug when the thousands separator |
| 163 | # is empty but the grouping array contains values (e.g. Solaris 10) |
Antoine Pitrou | ba54eda | 2008-07-25 20:40:19 +0000 | [diff] [blame] | 164 | |
| 165 | def setUp(self): |
Antoine Pitrou | ba54eda | 2008-07-25 20:40:19 +0000 | [diff] [blame] | 166 | self.sep = locale.localeconv()['thousands_sep'] |
| 167 | |
| 168 | def test_grouping(self): |
| 169 | self._test_format("%f", 1024, grouping=1, out='1%s024.000000' % self.sep) |
| 170 | self._test_format("%f", 102, grouping=1, out='102.000000') |
| 171 | self._test_format("%f", -42, grouping=1, out='-42.000000') |
| 172 | self._test_format("%+f", -42, grouping=1, out='-42.000000') |
| 173 | |
| 174 | def test_grouping_and_padding(self): |
| 175 | self._test_format("%20.f", -42, grouping=1, out='-42'.rjust(20)) |
Antoine Pitrou | 36897e1 | 2008-07-26 13:49:13 +0000 | [diff] [blame] | 176 | if self.sep: |
Antoine Pitrou | 524f413 | 2008-07-26 10:29:43 +0000 | [diff] [blame] | 177 | self._test_format("%+10.f", -4200, grouping=1, |
| 178 | out=('-4%s200' % self.sep).rjust(10)) |
| 179 | self._test_format("%-10.f", -4200, grouping=1, |
| 180 | out=('-4%s200' % self.sep).ljust(10)) |
Antoine Pitrou | ba54eda | 2008-07-25 20:40:19 +0000 | [diff] [blame] | 181 | |
| 182 | def test_integer_grouping(self): |
| 183 | self._test_format("%d", 4200, grouping=True, out='4%s200' % self.sep) |
| 184 | self._test_format("%+d", 4200, grouping=True, out='+4%s200' % self.sep) |
| 185 | self._test_format("%+d", -4200, grouping=True, out='-4%s200' % self.sep) |
| 186 | |
Antoine Pitrou | a099d14 | 2009-03-14 00:13:36 +0000 | [diff] [blame] | 187 | def test_integer_grouping_and_padding(self): |
| 188 | self._test_format("%10d", 4200, grouping=True, |
| 189 | out=('4%s200' % self.sep).rjust(10)) |
| 190 | self._test_format("%-10d", -4200, grouping=True, |
| 191 | out=('-4%s200' % self.sep).ljust(10)) |
| 192 | |
Antoine Pitrou | ba54eda | 2008-07-25 20:40:19 +0000 | [diff] [blame] | 193 | def test_simple(self): |
| 194 | self._test_format("%f", 1024, grouping=0, out='1024.000000') |
| 195 | self._test_format("%f", 102, grouping=0, out='102.000000') |
| 196 | self._test_format("%f", -42, grouping=0, out='-42.000000') |
| 197 | self._test_format("%+f", -42, grouping=0, out='-42.000000') |
| 198 | |
| 199 | def test_padding(self): |
| 200 | self._test_format("%20.f", -42, grouping=0, out='-42'.rjust(20)) |
| 201 | self._test_format("%+10.f", -4200, grouping=0, out='-4200'.rjust(10)) |
| 202 | self._test_format("%-10.f", 4200, grouping=0, out='4200'.ljust(10)) |
| 203 | |
| 204 | def test_complex_formatting(self): |
| 205 | # Spaces in formatting string |
| 206 | self._test_format_string("One million is %i", 1000000, grouping=1, |
| 207 | out='One million is 1%s000%s000' % (self.sep, self.sep)) |
| 208 | self._test_format_string("One million is %i", 1000000, grouping=1, |
| 209 | out='One million is 1%s000%s000' % (self.sep, self.sep)) |
| 210 | # Dots in formatting string |
| 211 | self._test_format_string(".%f.", 1000.0, out='.1000.000000.') |
| 212 | # Padding |
Antoine Pitrou | 36897e1 | 2008-07-26 13:49:13 +0000 | [diff] [blame] | 213 | if self.sep: |
| 214 | self._test_format_string("--> %10.2f", 4200, grouping=1, |
| 215 | out='--> ' + ('4%s200.00' % self.sep).rjust(10)) |
Antoine Pitrou | ba54eda | 2008-07-25 20:40:19 +0000 | [diff] [blame] | 216 | # Asterisk formats |
| 217 | self._test_format_string("%10.*f", (2, 1000), grouping=0, |
| 218 | out='1000.00'.rjust(10)) |
Antoine Pitrou | 36897e1 | 2008-07-26 13:49:13 +0000 | [diff] [blame] | 219 | if self.sep: |
| 220 | self._test_format_string("%*.*f", (10, 2, 1000), grouping=1, |
| 221 | out=('1%s000.00' % self.sep).rjust(10)) |
Antoine Pitrou | ba54eda | 2008-07-25 20:40:19 +0000 | [diff] [blame] | 222 | # Test more-in-one |
Antoine Pitrou | 36897e1 | 2008-07-26 13:49:13 +0000 | [diff] [blame] | 223 | if self.sep: |
| 224 | self._test_format_string("int %i float %.2f str %s", |
| 225 | (1000, 1000.0, 'str'), grouping=1, |
| 226 | out='int 1%s000 float 1%s000.00 str str' % |
| 227 | (self.sep, self.sep)) |
Antoine Pitrou | ba54eda | 2008-07-25 20:40:19 +0000 | [diff] [blame] | 228 | |
| 229 | |
| 230 | class TestNumberFormatting(BaseLocalizedTest, EnUSNumberFormatting): |
| 231 | # Test number formatting with a real English locale. |
| 232 | |
| 233 | locale_type = locale.LC_NUMERIC |
| 234 | |
| 235 | def setUp(self): |
| 236 | BaseLocalizedTest.setUp(self) |
| 237 | EnUSNumberFormatting.setUp(self) |
| 238 | |
| 239 | |
| 240 | class TestEnUSNumberFormatting(EnUSCookedTest, EnUSNumberFormatting): |
| 241 | # Test number formatting with a cooked "en_US" locale. |
| 242 | |
| 243 | def setUp(self): |
| 244 | EnUSCookedTest.setUp(self) |
| 245 | EnUSNumberFormatting.setUp(self) |
| 246 | |
| 247 | def test_currency(self): |
| 248 | self._test_currency(50000, "$50000.00") |
| 249 | self._test_currency(50000, "$50,000.00", grouping=True) |
| 250 | self._test_currency(50000, "USD 50,000.00", |
| 251 | grouping=True, international=True) |
| 252 | |
| 253 | |
| 254 | class TestCNumberFormatting(CCookedTest, BaseFormattingTest): |
| 255 | # Test number formatting with a cooked "C" locale. |
| 256 | |
| 257 | def test_grouping(self): |
| 258 | self._test_format("%.2f", 12345.67, grouping=True, out='12345.67') |
| 259 | |
| 260 | def test_grouping_and_padding(self): |
| 261 | self._test_format("%9.2f", 12345.67, grouping=True, out=' 12345.67') |
| 262 | |
| 263 | |
Antoine Pitrou | a099d14 | 2009-03-14 00:13:36 +0000 | [diff] [blame] | 264 | class TestFrFRNumberFormatting(FrFRCookedTest, BaseFormattingTest): |
| 265 | # Test number formatting with a cooked "fr_FR" locale. |
| 266 | |
| 267 | def test_decimal_point(self): |
| 268 | self._test_format("%.2f", 12345.67, out='12345,67') |
| 269 | |
| 270 | def test_grouping(self): |
| 271 | self._test_format("%.2f", 345.67, grouping=True, out='345,67') |
| 272 | self._test_format("%.2f", 12345.67, grouping=True, out='12 345,67') |
| 273 | |
| 274 | def test_grouping_and_padding(self): |
| 275 | self._test_format("%6.2f", 345.67, grouping=True, out='345,67') |
| 276 | self._test_format("%7.2f", 345.67, grouping=True, out=' 345,67') |
| 277 | self._test_format("%8.2f", 12345.67, grouping=True, out='12 345,67') |
| 278 | self._test_format("%9.2f", 12345.67, grouping=True, out='12 345,67') |
| 279 | self._test_format("%10.2f", 12345.67, grouping=True, out=' 12 345,67') |
| 280 | self._test_format("%-6.2f", 345.67, grouping=True, out='345,67') |
| 281 | self._test_format("%-7.2f", 345.67, grouping=True, out='345,67 ') |
| 282 | self._test_format("%-8.2f", 12345.67, grouping=True, out='12 345,67') |
| 283 | self._test_format("%-9.2f", 12345.67, grouping=True, out='12 345,67') |
| 284 | self._test_format("%-10.2f", 12345.67, grouping=True, out='12 345,67 ') |
| 285 | |
| 286 | def test_integer_grouping(self): |
| 287 | self._test_format("%d", 200, grouping=True, out='200') |
| 288 | self._test_format("%d", 4200, grouping=True, out='4 200') |
| 289 | |
| 290 | def test_integer_grouping_and_padding(self): |
| 291 | self._test_format("%4d", 4200, grouping=True, out='4 200') |
| 292 | self._test_format("%5d", 4200, grouping=True, out='4 200') |
| 293 | self._test_format("%10d", 4200, grouping=True, out='4 200'.rjust(10)) |
| 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'.ljust(10)) |
| 297 | |
| 298 | def test_currency(self): |
| 299 | euro = u'\u20ac'.encode('utf-8') |
| 300 | self._test_currency(50000, "50000,00 " + euro) |
| 301 | self._test_currency(50000, "50 000,00 " + euro, grouping=True) |
| 302 | # XXX is the trailing space a bug? |
| 303 | self._test_currency(50000, "50 000,00 EUR ", |
| 304 | grouping=True, international=True) |
| 305 | |
| 306 | |
Antoine Pitrou | 6327e84 | 2008-07-26 11:56:37 +0000 | [diff] [blame] | 307 | class TestStringMethods(BaseLocalizedTest): |
| 308 | locale_type = locale.LC_CTYPE |
Antoine Pitrou | ba54eda | 2008-07-25 20:40:19 +0000 | [diff] [blame] | 309 | |
Antoine Pitrou | 6327e84 | 2008-07-26 11:56:37 +0000 | [diff] [blame] | 310 | if sys.platform != 'sunos5' and not sys.platform.startswith("win"): |
Antoine Pitrou | 524f413 | 2008-07-26 10:29:43 +0000 | [diff] [blame] | 311 | # Test BSD Rune locale's bug for isctype functions. |
Antoine Pitrou | ba54eda | 2008-07-25 20:40:19 +0000 | [diff] [blame] | 312 | |
Antoine Pitrou | 524f413 | 2008-07-26 10:29:43 +0000 | [diff] [blame] | 313 | def test_isspace(self): |
| 314 | self.assertEqual('\x20'.isspace(), True) |
Antoine Pitrou | ba54eda | 2008-07-25 20:40:19 +0000 | [diff] [blame] | 315 | self.assertEqual('\xa0'.isspace(), False) |
Antoine Pitrou | 524f413 | 2008-07-26 10:29:43 +0000 | [diff] [blame] | 316 | self.assertEqual('\xa1'.isspace(), False) |
Antoine Pitrou | ba54eda | 2008-07-25 20:40:19 +0000 | [diff] [blame] | 317 | |
Antoine Pitrou | 524f413 | 2008-07-26 10:29:43 +0000 | [diff] [blame] | 318 | def test_isalpha(self): |
| 319 | self.assertEqual('\xc0'.isalpha(), False) |
Antoine Pitrou | ba54eda | 2008-07-25 20:40:19 +0000 | [diff] [blame] | 320 | |
Antoine Pitrou | 524f413 | 2008-07-26 10:29:43 +0000 | [diff] [blame] | 321 | def test_isalnum(self): |
| 322 | self.assertEqual('\xc0'.isalnum(), False) |
Antoine Pitrou | ba54eda | 2008-07-25 20:40:19 +0000 | [diff] [blame] | 323 | |
Antoine Pitrou | 524f413 | 2008-07-26 10:29:43 +0000 | [diff] [blame] | 324 | def test_isupper(self): |
| 325 | self.assertEqual('\xc0'.isupper(), False) |
Antoine Pitrou | ba54eda | 2008-07-25 20:40:19 +0000 | [diff] [blame] | 326 | |
Antoine Pitrou | 524f413 | 2008-07-26 10:29:43 +0000 | [diff] [blame] | 327 | def test_islower(self): |
| 328 | self.assertEqual('\xc0'.islower(), False) |
Antoine Pitrou | ba54eda | 2008-07-25 20:40:19 +0000 | [diff] [blame] | 329 | |
Antoine Pitrou | 524f413 | 2008-07-26 10:29:43 +0000 | [diff] [blame] | 330 | def test_lower(self): |
| 331 | self.assertEqual('\xcc\x85'.lower(), '\xcc\x85') |
Antoine Pitrou | ba54eda | 2008-07-25 20:40:19 +0000 | [diff] [blame] | 332 | |
Antoine Pitrou | 524f413 | 2008-07-26 10:29:43 +0000 | [diff] [blame] | 333 | def test_upper(self): |
| 334 | self.assertEqual('\xed\x95\xa0'.upper(), '\xed\x95\xa0') |
Antoine Pitrou | ba54eda | 2008-07-25 20:40:19 +0000 | [diff] [blame] | 335 | |
Antoine Pitrou | 524f413 | 2008-07-26 10:29:43 +0000 | [diff] [blame] | 336 | def test_strip(self): |
| 337 | self.assertEqual('\xed\x95\xa0'.strip(), '\xed\x95\xa0') |
Antoine Pitrou | ba54eda | 2008-07-25 20:40:19 +0000 | [diff] [blame] | 338 | |
Antoine Pitrou | 524f413 | 2008-07-26 10:29:43 +0000 | [diff] [blame] | 339 | def test_split(self): |
| 340 | self.assertEqual('\xec\xa0\xbc'.split(), ['\xec\xa0\xbc']) |
Antoine Pitrou | ba54eda | 2008-07-25 20:40:19 +0000 | [diff] [blame] | 341 | |
| 342 | |
| 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 | |
| 351 | if hasattr(locale, "strcoll"): |
| 352 | def test_strcoll_3303(self): |
| 353 | # test crasher from bug #3303 |
| 354 | self.assertRaises(TypeError, locale.strcoll, u"a", None) |
| 355 | |
| 356 | |
| 357 | def test_main(): |
Antoine Pitrou | 6327e84 | 2008-07-26 11:56:37 +0000 | [diff] [blame] | 358 | tests = [ |
| 359 | TestMiscellaneous, |
| 360 | TestEnUSNumberFormatting, |
Antoine Pitrou | a099d14 | 2009-03-14 00:13:36 +0000 | [diff] [blame] | 361 | TestCNumberFormatting, |
| 362 | TestFrFRNumberFormatting, |
Antoine Pitrou | 6327e84 | 2008-07-26 11:56:37 +0000 | [diff] [blame] | 363 | ] |
Antoine Pitrou | 524f413 | 2008-07-26 10:29:43 +0000 | [diff] [blame] | 364 | # TestSkipped can't be raised inside unittests, handle it manually instead |
| 365 | try: |
| 366 | get_enUS_locale() |
| 367 | except TestSkipped as e: |
Antoine Pitrou | 6327e84 | 2008-07-26 11:56:37 +0000 | [diff] [blame] | 368 | if verbose: |
| 369 | print "Some tests will be disabled: %s" % e |
Antoine Pitrou | 524f413 | 2008-07-26 10:29:43 +0000 | [diff] [blame] | 370 | else: |
| 371 | tests += [TestNumberFormatting, TestStringMethods] |
| 372 | run_unittest(*tests) |
Antoine Pitrou | ba54eda | 2008-07-25 20:40:19 +0000 | [diff] [blame] | 373 | |
| 374 | if __name__ == '__main__': |
| 375 | test_main() |