mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
Issue #20532: Tests which use _testcapi now are marked as CPython only.
This commit is contained in:
commit
f28ba369dd
29 changed files with 284 additions and 118 deletions
|
@ -332,19 +332,28 @@ class FormatTest(unittest.TestCase):
|
|||
self.assertIs(text % (), text)
|
||||
self.assertIs(text.format(), text)
|
||||
|
||||
@support.cpython_only
|
||||
def test_precision(self):
|
||||
from _testcapi import INT_MAX
|
||||
|
||||
f = 1.2
|
||||
self.assertEqual(format(f, ".0f"), "1")
|
||||
self.assertEqual(format(f, ".3f"), "1.200")
|
||||
with self.assertRaises(ValueError) as cm:
|
||||
format(f, ".%sf" % (INT_MAX + 1))
|
||||
format(f, ".%sf" % (sys.maxsize + 1))
|
||||
|
||||
c = complex(f)
|
||||
self.assertEqual(format(c, ".0f"), "1+0j")
|
||||
self.assertEqual(format(c, ".3f"), "1.200+0.000j")
|
||||
with self.assertRaises(ValueError) as cm:
|
||||
format(c, ".%sf" % (sys.maxsize + 1))
|
||||
|
||||
@support.cpython_only
|
||||
def test_precision_c_limits(self):
|
||||
from _testcapi import INT_MAX
|
||||
|
||||
f = 1.2
|
||||
with self.assertRaises(ValueError) as cm:
|
||||
format(f, ".%sf" % (INT_MAX + 1))
|
||||
|
||||
c = complex(f)
|
||||
with self.assertRaises(ValueError) as cm:
|
||||
format(c, ".%sf" % (INT_MAX + 1))
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue