| 579 | self.assertEqual(format(0j, "\u2007^4"), "\u20070j\u2007") |
| 580 | |
| 581 | def test_locale(self): |
| 582 | try: |
| 583 | oldloc = locale.setlocale(locale.LC_ALL) |
| 584 | locale.setlocale(locale.LC_ALL, '') |
| 585 | except locale.Error as err: |
| 586 | self.skipTest("Cannot set locale: {}".format(err)) |
| 587 | try: |
| 588 | localeconv = locale.localeconv() |
| 589 | sep = localeconv['thousands_sep'] |
| 590 | point = localeconv['decimal_point'] |
| 591 | grouping = localeconv['grouping'] |
| 592 | |
| 593 | text = format(123456789, "n") |
| 594 | if grouping: |
| 595 | self.assertIn(sep, text) |
| 596 | self.assertEqual(text.replace(sep, ''), '123456789') |
| 597 | |
| 598 | text = format(1234.5, "n") |
| 599 | if grouping: |
| 600 | self.assertIn(sep, text) |
| 601 | self.assertIn(point, text) |
| 602 | self.assertEqual(text.replace(sep, ''), '1234' + point + '5') |
| 603 | finally: |
| 604 | locale.setlocale(locale.LC_ALL, oldloc) |
| 605 | |
| 606 | @support.cpython_only |
| 607 | def test_optimisations(self): |