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

Method test_precision

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

Source from the content-addressed store, hash-verified

624 self.assertIs(text.format(), text)
625
626 def test_precision(self):
627 f = 1.2
628 self.assertEqual(format(f, ".0f"), "1")
629 self.assertEqual(format(f, ".3f"), "1.200")
630 with self.assertRaises(ValueError) as cm:
631 format(f, ".%sf" % (sys.maxsize + 1))
632
633 c = complex(f)
634 self.assertEqual(format(c, ".0f"), "1+0j")
635 self.assertEqual(format(c, ".3f"), "1.200+0.000j")
636 with self.assertRaises(ValueError) as cm:
637 format(c, ".%sf" % (sys.maxsize + 1))
638
639 @support.cpython_only
640 def test_precision_c_limits(self):

Callers

nothing calls this directly

Calls 3

formatFunction · 0.85
assertEqualMethod · 0.45
assertRaisesMethod · 0.45

Tested by

no test coverage detected