| 425 | |
| 426 | @unittest.expectedFailureIfWindows("TODO: RUSTPYTHON; AssertionError: ',' not found in '123456789'") |
| 427 | def test_locale(self): |
| 428 | try: |
| 429 | oldloc = locale.setlocale(locale.LC_ALL) |
| 430 | locale.setlocale(locale.LC_ALL, '') |
| 431 | except locale.Error as err: |
| 432 | self.skipTest("Cannot set locale: {}".format(err)) |
| 433 | try: |
| 434 | localeconv = locale.localeconv() |
| 435 | sep = localeconv['thousands_sep'] |
| 436 | point = localeconv['decimal_point'] |
| 437 | grouping = localeconv['grouping'] |
| 438 | |
| 439 | text = format(123456789, "n") |
| 440 | if grouping: |
| 441 | self.assertIn(sep, text) |
| 442 | self.assertEqual(text.replace(sep, ''), '123456789') |
| 443 | |
| 444 | text = format(1234.5, "n") |
| 445 | if grouping: |
| 446 | self.assertIn(sep, text) |
| 447 | self.assertIn(point, text) |
| 448 | self.assertEqual(text.replace(sep, ''), '1234' + point + '5') |
| 449 | finally: |
| 450 | locale.setlocale(locale.LC_ALL, oldloc) |
| 451 | |
| 452 | @support.cpython_only |
| 453 | def test_optimisations(self): |