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

Method test_lc_numeric_basic

Lib/test/test__locale.py:178–203  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

176
177 @unittest.skipUnless(nl_langinfo, "nl_langinfo is not available")
178 def test_lc_numeric_basic(self):
179 # Test nl_langinfo against localeconv
180 tested = False
181 oldloc = setlocale(LC_CTYPE)
182 for loc in candidate_locales:
183 try:
184 setlocale(LC_NUMERIC, loc)
185 except Error:
186 continue
187 for li, lc in ((RADIXCHAR, "decimal_point"),
188 (THOUSEP, "thousands_sep")):
189 nl_radixchar = nl_langinfo(li)
190 li_radixchar = localeconv()[lc]
191 try:
192 set_locale = setlocale(LC_NUMERIC)
193 except Error:
194 set_locale = "<not able to determine>"
195 self.assertEqual(nl_radixchar, li_radixchar,
196 "%s (nl_langinfo) != %s (localeconv) "
197 "(set to %s, using %s)" % (
198 nl_radixchar, li_radixchar,
199 loc, set_locale))
200 tested = True
201 self.assertEqual(setlocale(LC_CTYPE), oldloc)
202 if not tested:
203 self.skipTest('no suitable locales')
204
205 @unittest.skipUnless(nl_langinfo, "nl_langinfo is not available")
206 @unittest.skipUnless(hasattr(locale, 'ALT_DIGITS'), "requires locale.ALT_DIGITS")

Callers

nothing calls this directly

Calls 4

setlocaleFunction · 0.85
localeconvFunction · 0.85
skipTestMethod · 0.80
assertEqualMethod · 0.45

Tested by

no test coverage detected