MCPcopy Index your code
hub / github.com/python/cpython / test_locale

Method test_locale

Lib/test/test_format.py:581–604  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

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):

Callers

nothing calls this directly

Calls 6

formatFunction · 0.85
skipTestMethod · 0.80
assertInMethod · 0.80
formatMethod · 0.45
assertEqualMethod · 0.45
replaceMethod · 0.45

Tested by

no test coverage detected