self.assertEqual('%f' % INF, 'inf')
self.assertEqual('%F' % INF, 'INF')
+ # PEP 393
+ self.assertEqual('%.1s' % "a\xe9\u20ac", 'a')
+ self.assertEqual('%.2s' % "a\xe9\u20ac", 'a\xe9')
+
+ @support.cpython_only
+ def test_formatting_huge_precision(self):
+ from _testcapi import INT_MAX
+ format_string = "%.{}f".format(INT_MAX + 1)
+ with self.assertRaises(ValueError):
+ result = format_string % 2.34
+
+ def test_formatting_huge_width(self):
+ format_string = "%{}f".format(sys.maxsize + 1)
+ with self.assertRaises(ValueError):
+ result = format_string % 2.34
+
def test_startswith_endswith_errors(self):
for meth in ('foo'.startswith, 'foo'.endswith):
with self.assertRaises(TypeError) as cm: