Skip to content

Commit 902356a

Browse files
authored
bpo-41338: Fix DeprecationWarning in tests (GH-21542)
1 parent bfd0fbd commit 902356a

3 files changed

Lines changed: 11 additions & 0 deletions

File tree

Lib/test/test_capi.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from test.support import MISSING_C_DOCSTRINGS
2020
from test.support import import_helper
2121
from test.support import threading_helper
22+
from test.support import warnings_helper
2223
from test.support.script_helper import assert_python_failure, assert_python_ok
2324
try:
2425
import _posixsubprocess
@@ -700,6 +701,11 @@ class Test_testcapi(unittest.TestCase):
700701
for name in dir(_testcapi)
701702
if name.startswith('test_') and not name.endswith('_code'))
702703

704+
# Suppress warning from PyUnicode_FromUnicode().
705+
@warnings_helper.ignore_warnings(category=DeprecationWarning)
706+
def test_widechar(self):
707+
_testcapi.test_widechar()
708+
703709

704710
class Test_testinternalcapi(unittest.TestCase):
705711
locals().update((name, getattr(_testinternalcapi, name))

Lib/test/test_csv.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import gc
1111
import pickle
1212
from test import support
13+
from test.support import warnings_helper
1314
from itertools import permutations
1415
from textwrap import dedent
1516
from collections import OrderedDict
@@ -251,6 +252,7 @@ def test_writerows_errors(self):
251252

252253
@support.cpython_only
253254
@support.requires_legacy_unicode_capi
255+
@warnings_helper.ignore_warnings(category=DeprecationWarning)
254256
def test_writerows_legacy_strings(self):
255257
import _testcapi
256258
c = _testcapi.unicode_legacy_string('a')

Lib/test/test_decimal.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
from test.support import (TestFailed,
3939
run_with_locale, cpython_only)
4040
from test.support.import_helper import import_fresh_module
41+
from test.support import warnings_helper
4142
import random
4243
import inspect
4344
import threading
@@ -584,6 +585,7 @@ def test_explicit_from_string(self):
584585

585586
@cpython_only
586587
@requires_legacy_unicode_capi
588+
@warnings_helper.ignore_warnings(category=DeprecationWarning)
587589
def test_from_legacy_strings(self):
588590
import _testcapi
589591
Decimal = self.decimal.Decimal
@@ -2820,6 +2822,7 @@ def test_none_args(self):
28202822

28212823
@cpython_only
28222824
@requires_legacy_unicode_capi
2825+
@warnings_helper.ignore_warnings(category=DeprecationWarning)
28232826
def test_from_legacy_strings(self):
28242827
import _testcapi
28252828
c = self.decimal.Context()

0 commit comments

Comments
 (0)