from .testresult import get_test_runner
-try:
- from _testcapi import unicode_legacy_string
-except ImportError:
- unicode_legacy_string = None
-
__all__ = [
# globals
"PIPE_MAX_SIZE", "verbose", "max_memuse", "use_resources", "failfast",
def requires_debug_ranges(reason='requires co_positions / debug_ranges'):
return unittest.skipIf(has_no_debug_ranges(), reason)
-requires_legacy_unicode_capi = unittest.skipUnless(unicode_legacy_string,
- 'requires legacy Unicode C API')
+def requires_legacy_unicode_capi():
+ try:
+ from _testcapi import unicode_legacy_string
+ except ImportError:
+ unicode_legacy_string = None
+
+ return unittest.skipUnless(unicode_legacy_string,
+ 'requires legacy Unicode C API')
# Is not actually used in tests, but is kept for compatibility.
is_jython = sys.platform.startswith('java')
buf = bytearray()
self.assertRaises(ValueError, getargs_et_hash, 'abc\xe9', 'latin1', buf)
- @support.requires_legacy_unicode_capi
+ @support.requires_legacy_unicode_capi()
def test_u(self):
from _testcapi import getargs_u
with self.assertWarns(DeprecationWarning):
with self.assertWarns(DeprecationWarning):
self.assertRaises(TypeError, getargs_u, None)
- @support.requires_legacy_unicode_capi
+ @support.requires_legacy_unicode_capi()
def test_u_hash(self):
from _testcapi import getargs_u_hash
with self.assertWarns(DeprecationWarning):
with self.assertWarns(DeprecationWarning):
self.assertRaises(TypeError, getargs_u_hash, None)
- @support.requires_legacy_unicode_capi
+ @support.requires_legacy_unicode_capi()
def test_Z(self):
from _testcapi import getargs_Z
with self.assertWarns(DeprecationWarning):
with self.assertWarns(DeprecationWarning):
self.assertIsNone(getargs_Z(None))
- @support.requires_legacy_unicode_capi
+ @support.requires_legacy_unicode_capi()
def test_Z_hash(self):
from _testcapi import getargs_Z_hash
with self.assertWarns(DeprecationWarning):
self.assertRaises(OSError, writer.writerows, BadIterable())
@support.cpython_only
- @support.requires_legacy_unicode_capi
+ @support.requires_legacy_unicode_capi()
@warnings_helper.ignore_warnings(category=DeprecationWarning)
def test_writerows_legacy_strings(self):
import _testcapi
self.assertRaises(InvalidOperation, Decimal, "1_2_\u00003")
@cpython_only
- @requires_legacy_unicode_capi
+ @requires_legacy_unicode_capi()
@warnings_helper.ignore_warnings(category=DeprecationWarning)
def test_from_legacy_strings(self):
import _testcapi
Overflow])
@cpython_only
- @requires_legacy_unicode_capi
+ @requires_legacy_unicode_capi()
@warnings_helper.ignore_warnings(category=DeprecationWarning)
def test_from_legacy_strings(self):
import _testcapi
self.assertFalse("0".isidentifier())
@support.cpython_only
- @support.requires_legacy_unicode_capi
+ @support.requires_legacy_unicode_capi()
@unittest.skipIf(_testcapi is None, 'need _testcapi module')
def test_isidentifier_legacy(self):
u = '𝖀𝖓𝖎𝖈𝖔𝖉𝖊'
self.assertEqual(len(args), 1)
@support.cpython_only
- @support.requires_legacy_unicode_capi
+ @support.requires_legacy_unicode_capi()
@unittest.skipIf(_testcapi is None, 'need _testcapi module')
def test_resize(self):
for length in range(1, 100, 7):