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

Method test_float_parsing

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

Source from the content-addressed store, hash-verified

269 self.skipTest('no suitable locales')
270
271 def test_float_parsing(self):
272 # Bug #1391872: Test whether float parsing is okay on European
273 # locales.
274 tested = False
275 oldloc = setlocale(LC_CTYPE)
276 for loc in candidate_locales:
277 try:
278 setlocale(LC_NUMERIC, loc)
279 except Error:
280 continue
281
282 # Ignore buggy locale databases. (Mac OS 10.4 and some other BSDs)
283 if loc == 'eu_ES' and localeconv()['decimal_point'] == "' ":
284 continue
285
286 self.assertEqual(int(eval('3.14') * 100), 314,
287 "using eval('3.14') failed for %s" % loc)
288 self.assertEqual(int(float('3.14') * 100), 314,
289 "using float('3.14') failed for %s" % loc)
290 if localeconv()['decimal_point'] != '.':
291 self.assertRaises(ValueError, float,
292 localeconv()['decimal_point'].join(['1', '23']))
293 tested = True
294 self.assertEqual(setlocale(LC_CTYPE), oldloc)
295 if not tested:
296 self.skipTest('no suitable locales')
297
298
299if __name__ == '__main__':

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected