mirror of
https://github.com/python/cpython.git
synced 2025-12-11 19:40:17 +00:00
bpo-41338: Fix DeprecationWarning in tests (GH-21542)
This commit is contained in:
parent
bfd0fbdc13
commit
902356a7b0
3 changed files with 11 additions and 0 deletions
|
|
@ -19,6 +19,7 @@ from test import support
|
||||||
from test.support import MISSING_C_DOCSTRINGS
|
from test.support import MISSING_C_DOCSTRINGS
|
||||||
from test.support import import_helper
|
from test.support import import_helper
|
||||||
from test.support import threading_helper
|
from test.support import threading_helper
|
||||||
|
from test.support import warnings_helper
|
||||||
from test.support.script_helper import assert_python_failure, assert_python_ok
|
from test.support.script_helper import assert_python_failure, assert_python_ok
|
||||||
try:
|
try:
|
||||||
import _posixsubprocess
|
import _posixsubprocess
|
||||||
|
|
@ -700,6 +701,11 @@ class Test_testcapi(unittest.TestCase):
|
||||||
for name in dir(_testcapi)
|
for name in dir(_testcapi)
|
||||||
if name.startswith('test_') and not name.endswith('_code'))
|
if name.startswith('test_') and not name.endswith('_code'))
|
||||||
|
|
||||||
|
# Suppress warning from PyUnicode_FromUnicode().
|
||||||
|
@warnings_helper.ignore_warnings(category=DeprecationWarning)
|
||||||
|
def test_widechar(self):
|
||||||
|
_testcapi.test_widechar()
|
||||||
|
|
||||||
|
|
||||||
class Test_testinternalcapi(unittest.TestCase):
|
class Test_testinternalcapi(unittest.TestCase):
|
||||||
locals().update((name, getattr(_testinternalcapi, name))
|
locals().update((name, getattr(_testinternalcapi, name))
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ import csv
|
||||||
import gc
|
import gc
|
||||||
import pickle
|
import pickle
|
||||||
from test import support
|
from test import support
|
||||||
|
from test.support import warnings_helper
|
||||||
from itertools import permutations
|
from itertools import permutations
|
||||||
from textwrap import dedent
|
from textwrap import dedent
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
|
|
@ -251,6 +252,7 @@ class Test_Csv(unittest.TestCase):
|
||||||
|
|
||||||
@support.cpython_only
|
@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):
|
def test_writerows_legacy_strings(self):
|
||||||
import _testcapi
|
import _testcapi
|
||||||
c = _testcapi.unicode_legacy_string('a')
|
c = _testcapi.unicode_legacy_string('a')
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,7 @@ from test.support import (run_unittest, run_doctest, is_resource_enabled,
|
||||||
from test.support import (TestFailed,
|
from test.support import (TestFailed,
|
||||||
run_with_locale, cpython_only)
|
run_with_locale, cpython_only)
|
||||||
from test.support.import_helper import import_fresh_module
|
from test.support.import_helper import import_fresh_module
|
||||||
|
from test.support import warnings_helper
|
||||||
import random
|
import random
|
||||||
import inspect
|
import inspect
|
||||||
import threading
|
import threading
|
||||||
|
|
@ -584,6 +585,7 @@ class ExplicitConstructionTest(unittest.TestCase):
|
||||||
|
|
||||||
@cpython_only
|
@cpython_only
|
||||||
@requires_legacy_unicode_capi
|
@requires_legacy_unicode_capi
|
||||||
|
@warnings_helper.ignore_warnings(category=DeprecationWarning)
|
||||||
def test_from_legacy_strings(self):
|
def test_from_legacy_strings(self):
|
||||||
import _testcapi
|
import _testcapi
|
||||||
Decimal = self.decimal.Decimal
|
Decimal = self.decimal.Decimal
|
||||||
|
|
@ -2820,6 +2822,7 @@ class ContextAPItests(unittest.TestCase):
|
||||||
|
|
||||||
@cpython_only
|
@cpython_only
|
||||||
@requires_legacy_unicode_capi
|
@requires_legacy_unicode_capi
|
||||||
|
@warnings_helper.ignore_warnings(category=DeprecationWarning)
|
||||||
def test_from_legacy_strings(self):
|
def test_from_legacy_strings(self):
|
||||||
import _testcapi
|
import _testcapi
|
||||||
c = self.decimal.Context()
|
c = self.decimal.Context()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue