mirror of
https://github.com/python/cpython.git
synced 2025-08-22 17:55:18 +00:00
Issue #20532: Tests which use _testcapi now are marked as CPython only.
This commit is contained in:
parent
fe4ef392d5
commit
5cfc79deae
25 changed files with 239 additions and 106 deletions
|
@ -5,7 +5,6 @@ Common tests shared by test_str, test_unicode, test_userstring and test_string.
|
|||
import unittest, string, sys, struct
|
||||
from test import support
|
||||
from collections import UserList
|
||||
import _testcapi
|
||||
|
||||
class Sequence:
|
||||
def __init__(self, seq='wxyz'): self.seq = seq
|
||||
|
@ -1185,20 +1184,28 @@ class MixinStrUnicodeUserStringTest:
|
|||
# Outrageously large width or precision should raise ValueError.
|
||||
self.checkraises(ValueError, '%%%df' % (2**64), '__mod__', (3.2))
|
||||
self.checkraises(ValueError, '%%.%df' % (2**64), '__mod__', (3.2))
|
||||
|
||||
self.checkraises(OverflowError, '%*s', '__mod__',
|
||||
(_testcapi.PY_SSIZE_T_MAX + 1, ''))
|
||||
(sys.maxsize + 1, ''))
|
||||
self.checkraises(OverflowError, '%.*f', '__mod__',
|
||||
(_testcapi.INT_MAX + 1, 1. / 7))
|
||||
# Issue 15989
|
||||
self.checkraises(OverflowError, '%*s', '__mod__',
|
||||
(1 << (_testcapi.PY_SSIZE_T_MAX.bit_length() + 1), ''))
|
||||
self.checkraises(OverflowError, '%.*f', '__mod__',
|
||||
(_testcapi.UINT_MAX + 1, 1. / 7))
|
||||
(sys.maxsize + 1, 1. / 7))
|
||||
|
||||
class X(object): pass
|
||||
self.checkraises(TypeError, 'abc', '__mod__', X())
|
||||
|
||||
@support.cpython_only
|
||||
def test_formatting_c_limits(self):
|
||||
from _testcapi import PY_SSIZE_T_MAX, INT_MAX, UINT_MAX
|
||||
SIZE_MAX = (1 << (PY_SSIZE_T_MAX.bit_length() + 1)) - 1
|
||||
self.checkraises(OverflowError, '%*s', '__mod__',
|
||||
(PY_SSIZE_T_MAX + 1, ''))
|
||||
self.checkraises(OverflowError, '%.*f', '__mod__',
|
||||
(INT_MAX + 1, 1. / 7))
|
||||
# Issue 15989
|
||||
self.checkraises(OverflowError, '%*s', '__mod__',
|
||||
(SIZE_MAX + 1, ''))
|
||||
self.checkraises(OverflowError, '%.*f', '__mod__',
|
||||
(UINT_MAX + 1, 1. / 7))
|
||||
|
||||
def test_floatformatting(self):
|
||||
# float formatting
|
||||
for prec in range(100):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue