summaryrefslogtreecommitdiffstats
path: root/Lib/test/string_tests.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2014-02-07 08:10:55 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2014-02-07 08:10:55 (GMT)
commitf28ba369dd068a76ff5b7efac58fdcb5c3eaf4dd (patch)
tree541cb209a2be79d6022ce5d47216755e9e9310a4 /Lib/test/string_tests.py
parent622be340fdf4110c77e1f86bd13a01fc30c2bb65 (diff)
parent5cfc79deaeabf4af3c767665098a37da9f375eda (diff)
downloadcpython-f28ba369dd068a76ff5b7efac58fdcb5c3eaf4dd.zip
cpython-f28ba369dd068a76ff5b7efac58fdcb5c3eaf4dd.tar.gz
cpython-f28ba369dd068a76ff5b7efac58fdcb5c3eaf4dd.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 4345687..5ed01f2 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
@@ -1199,19 +1198,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