summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test')
-rwxr-xr-xLib/test/test_array.py19
-rw-r--r--Lib/test/test_buffer.py16
-rw-r--r--Lib/test/test_re.py5
3 files changed, 31 insertions, 9 deletions
diff --git a/Lib/test/test_array.py b/Lib/test/test_array.py
index a94d04f..f6bf9e6 100755
--- a/Lib/test/test_array.py
+++ b/Lib/test/test_array.py
@@ -13,11 +13,14 @@ import pickle
import operator
import struct
import sys
+import warnings
import array
from array import _array_reconstructor as array_reconstructor
-sizeof_wchar = array.array('u').itemsize
+with warnings.catch_warnings():
+ warnings.simplefilter('ignore', DeprecationWarning)
+ sizeof_wchar = array.array('u').itemsize
class ArraySubclass(array.array):
@@ -93,8 +96,16 @@ UTF16_BE = 19
UTF32_LE = 20
UTF32_BE = 21
+
class ArrayReconstructorTest(unittest.TestCase):
+ def setUp(self):
+ warnings.filterwarnings(
+ "ignore",
+ message="The 'u' type code is deprecated and "
+ "will be removed in Python 3.16",
+ category=DeprecationWarning)
+
def test_error(self):
self.assertRaises(TypeError, array_reconstructor,
"", "b", 0, b"")
@@ -1208,10 +1219,16 @@ class UnicodeTest(StringTest, unittest.TestCase):
self.assertRaises(ValueError, a.tounicode)
self.assertRaises(ValueError, str, a)
+ def test_typecode_u_deprecation(self):
+ with self.assertWarns(DeprecationWarning):
+ array.array("u")
+
+
class UCS4Test(UnicodeTest):
typecode = 'w'
minitemsize = 4
+
class NumberTest(BaseTest):
def test_extslice(self):
diff --git a/Lib/test/test_buffer.py b/Lib/test/test_buffer.py
index 94fc9d4..8d6902e 100644
--- a/Lib/test/test_buffer.py
+++ b/Lib/test/test_buffer.py
@@ -24,6 +24,7 @@ import warnings
import sys, array, io, os
from decimal import Decimal
from fractions import Fraction
+from test.support import warnings_helper
try:
from _testbuffer import *
@@ -3217,12 +3218,6 @@ class TestBufferProtocol(unittest.TestCase):
nd[0] = (-1, float('nan'))
self.assertNotEqual(memoryview(nd), nd)
- # Depends on issue #15625: the struct module does not understand 'u'.
- a = array.array('u', 'xyz')
- v = memoryview(a)
- self.assertNotEqual(a, v)
- self.assertNotEqual(v, a)
-
# Some ctypes format strings are unknown to the struct module.
if ctypes:
# format: "T{>l:x:>l:y:}"
@@ -3236,6 +3231,15 @@ class TestBufferProtocol(unittest.TestCase):
self.assertNotEqual(point, a)
self.assertRaises(NotImplementedError, a.tolist)
+ @warnings_helper.ignore_warnings(category=DeprecationWarning) # gh-80480 array('u')
+ def test_memoryview_compare_special_cases_deprecated_u_type_code(self):
+
+ # Depends on issue #15625: the struct module does not understand 'u'.
+ a = array.array('u', 'xyz')
+ v = memoryview(a)
+ self.assertNotEqual(a, v)
+ self.assertNotEqual(v, a)
+
def test_memoryview_compare_ndim_zero(self):
nd1 = ndarray(1729, shape=[], format='@L')
diff --git a/Lib/test/test_re.py b/Lib/test/test_re.py
index 11628a2..d1575dc 100644
--- a/Lib/test/test_re.py
+++ b/Lib/test/test_re.py
@@ -1,7 +1,7 @@
from test.support import (gc_collect, bigmemtest, _2G,
cpython_only, captured_stdout,
check_disallow_instantiation, is_emscripten, is_wasi,
- SHORT_TIMEOUT)
+ warnings_helper, SHORT_TIMEOUT)
import locale
import re
import string
@@ -1522,10 +1522,11 @@ class ReTests(unittest.TestCase):
for x in not_decimal_digits:
self.assertIsNone(re.match(r'^\d$', x))
+ @warnings_helper.ignore_warnings(category=DeprecationWarning) # gh-80480 array('u')
def test_empty_array(self):
# SF buf 1647541
import array
- for typecode in 'bBuhHiIlLfd':
+ for typecode in 'bBhuwHiIlLfd':
a = array.array(typecode)
self.assertIsNone(re.compile(b"bla").match(a))
self.assertEqual(re.compile(b"").match(a).groups(), ())