aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/test/test_array.py
diff options
context:
space:
mode:
authorHugo van Kemenade <hugovk@users.noreply.github.com>2023-06-11 12:17:35 +0300
committerGitHub <noreply@github.com>2023-06-11 03:17:35 -0600
commitcc879481e2ac29742ce191f4c6ed4bd85e5e11ba (patch)
treeec351755d6df819ba80a6530dd822d16972c809a /Lib/test/test_array.py
parent3a314f7c3df0dd7c37da7d12b827f169ee60e1ea (diff)
downloadcpython-cc879481e2ac29742ce191f4c6ed4bd85e5e11ba.tar.gz
cpython-cc879481e2ac29742ce191f4c6ed4bd85e5e11ba.zip
gh-80480: Emit DeprecationWarning for array's 'u' type code (#95760)
Diffstat (limited to 'Lib/test/test_array.py')
-rwxr-xr-xLib/test/test_array.py19
1 files changed, 18 insertions, 1 deletions
diff --git a/Lib/test/test_array.py b/Lib/test/test_array.py
index a94d04f6515..f6bf9e6c5ea 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):