Commit ef8627b3 authored by Mark Dickinson's avatar Mark Dickinson

Issue #18659: fix test_format test that wasn't being executed. Thanks Vajrasky Kok for the patch.

parent 31f6f4dd
...@@ -327,12 +327,9 @@ class FormatTest(unittest.TestCase): ...@@ -327,12 +327,9 @@ class FormatTest(unittest.TestCase):
self.assertIs(text % (), text) self.assertIs(text % (), text)
self.assertIs(text.format(), text) self.assertIs(text.format(), text)
@support.cpython_only
def test_main():
support.run_unittest(FormatTest)
def test_precision(self): def test_precision(self):
INT_MAX = 2147483647 from _testcapi import INT_MAX
f = 1.2 f = 1.2
self.assertEqual(format(f, ".0f"), "1") self.assertEqual(format(f, ".0f"), "1")
...@@ -342,10 +339,10 @@ def test_main(): ...@@ -342,10 +339,10 @@ def test_main():
self.assertEqual(str(cm.exception), "precision too big") self.assertEqual(str(cm.exception), "precision too big")
c = complex(f) c = complex(f)
self.assertEqual(format(f, ".0f"), "1") self.assertEqual(format(c, ".0f"), "1+0j")
self.assertEqual(format(f, ".3f"), "1.200") self.assertEqual(format(c, ".3f"), "1.200+0.000j")
with self.assertRaises(ValueError) as cm: with self.assertRaises(ValueError) as cm:
format(f, ".%sf" % (INT_MAX + 1)) format(c, ".%sf" % (INT_MAX + 1))
self.assertEqual(str(cm.exception), "precision too big") self.assertEqual(str(cm.exception), "precision too big")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment