summaryrefslogtreecommitdiffstats
path: root/Lib/test/string_tests.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2014-02-07 08:06:39 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2014-02-07 08:06:39 (GMT)
commit5cfc79deaeabf4af3c767665098a37da9f375eda (patch)
tree2696e5c9674d11398f0d207d58d1fcdd3ee420eb /Lib/test/string_tests.py
parentfe4ef392d5df73639337f02db2ad8100d615067d (diff)
downloadcpython-5cfc79deaeabf4af3c767665098a37da9f375eda.zip
cpython-5cfc79deaeabf4af3c767665098a37da9f375eda.tar.gz
cpython-5cfc79deaeabf4af3c767665098a37da9f375eda.tar.bz2
Issue #20532: Tests which use _testcapi now are marked as CPython only.
Diffstat (limited to 'Lib/test/string_tests.py')
-rw-r--r--Lib/test/string_tests.py23
1 files changed, 15 insertions, 8 deletions
diff --git a/Lib/test/string_tests.py b/Lib/test/string_tests.py
index 1b5db94..4800d6d 100644
--- a/Lib/test/string_tests.py
+++ b/Lib/test/string_tests.py
@@ -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,19 +1184,27 @@ 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__',
+ (sys.maxsize + 1, ''))
+ self.checkraises(OverflowError, '%.*f', '__mod__',
+ (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__',
- (_testcapi.PY_SSIZE_T_MAX + 1, ''))
+ (PY_SSIZE_T_MAX + 1, ''))
self.checkraises(OverflowError, '%.*f', '__mod__',
- (_testcapi.INT_MAX + 1, 1. / 7))
+ (INT_MAX + 1, 1. / 7))
# Issue 15989
self.checkraises(OverflowError, '%*s', '__mod__',
- (1 << (_testcapi.PY_SSIZE_T_MAX.bit_length() + 1), ''))
+ (SIZE_MAX + 1, ''))
self.checkraises(OverflowError, '%.*f', '__mod__',
- (_testcapi.UINT_MAX + 1, 1. / 7))
-
- class X(object): pass
- self.checkraises(TypeError, 'abc', '__mod__', X())
+ (UINT_MAX + 1, 1. / 7))
def test_floatformatting(self):
# float formatting