mirror of
https://github.com/python/cpython.git
synced 2025-09-27 18:59:43 +00:00
Issue #19760: Silence sysconfig's 'SO' key deprecation warnings in tests.
Change stacklevel in warnings.warn() for 'SO' key to 2.
This commit is contained in:
parent
59463d8340
commit
eaec3597dd
4 changed files with 10 additions and 8 deletions
|
@ -575,5 +575,5 @@ def get_config_var(name):
|
||||||
"""
|
"""
|
||||||
if name == 'SO':
|
if name == 'SO':
|
||||||
import warnings
|
import warnings
|
||||||
warnings.warn('SO is deprecated, use EXT_SUFFIX', DeprecationWarning)
|
warnings.warn('SO is deprecated, use EXT_SUFFIX', DeprecationWarning, 2)
|
||||||
return get_config_vars().get(name)
|
return get_config_vars().get(name)
|
||||||
|
|
|
@ -6,7 +6,7 @@ import unittest
|
||||||
from distutils import sysconfig
|
from distutils import sysconfig
|
||||||
from distutils.ccompiler import get_default_compiler
|
from distutils.ccompiler import get_default_compiler
|
||||||
from distutils.tests import support
|
from distutils.tests import support
|
||||||
from test.support import TESTFN, run_unittest
|
from test.support import TESTFN, run_unittest, check_warnings
|
||||||
|
|
||||||
class SysconfigTestCase(support.EnvironGuard, unittest.TestCase):
|
class SysconfigTestCase(support.EnvironGuard, unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
@ -166,6 +166,7 @@ class SysconfigTestCase(support.EnvironGuard, unittest.TestCase):
|
||||||
@unittest.skipIf(sysconfig.get_config_var('EXT_SUFFIX') is None,
|
@unittest.skipIf(sysconfig.get_config_var('EXT_SUFFIX') is None,
|
||||||
'EXT_SUFFIX required for this test')
|
'EXT_SUFFIX required for this test')
|
||||||
def test_SO_value(self):
|
def test_SO_value(self):
|
||||||
|
with check_warnings(('', DeprecationWarning)):
|
||||||
self.assertEqual(sysconfig.get_config_var('SO'),
|
self.assertEqual(sysconfig.get_config_var('SO'),
|
||||||
sysconfig.get_config_var('EXT_SUFFIX'))
|
sysconfig.get_config_var('EXT_SUFFIX'))
|
||||||
|
|
||||||
|
|
|
@ -585,7 +585,7 @@ def get_config_var(name):
|
||||||
"""
|
"""
|
||||||
if name == 'SO':
|
if name == 'SO':
|
||||||
import warnings
|
import warnings
|
||||||
warnings.warn('SO is deprecated, use EXT_SUFFIX', DeprecationWarning)
|
warnings.warn('SO is deprecated, use EXT_SUFFIX', DeprecationWarning, 2)
|
||||||
return get_config_vars().get(name)
|
return get_config_vars().get(name)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ import subprocess
|
||||||
import shutil
|
import shutil
|
||||||
from copy import copy
|
from copy import copy
|
||||||
|
|
||||||
from test.support import (run_unittest, TESTFN, unlink,
|
from test.support import (run_unittest, TESTFN, unlink, check_warnings,
|
||||||
captured_stdout, skip_unless_symlink)
|
captured_stdout, skip_unless_symlink)
|
||||||
|
|
||||||
import sysconfig
|
import sysconfig
|
||||||
|
@ -378,6 +378,7 @@ class TestSysConfig(unittest.TestCase):
|
||||||
@unittest.skipIf(sysconfig.get_config_var('EXT_SUFFIX') is None,
|
@unittest.skipIf(sysconfig.get_config_var('EXT_SUFFIX') is None,
|
||||||
'EXT_SUFFIX required for this test')
|
'EXT_SUFFIX required for this test')
|
||||||
def test_SO_value(self):
|
def test_SO_value(self):
|
||||||
|
with check_warnings(('', DeprecationWarning)):
|
||||||
self.assertEqual(sysconfig.get_config_var('SO'),
|
self.assertEqual(sysconfig.get_config_var('SO'),
|
||||||
sysconfig.get_config_var('EXT_SUFFIX'))
|
sysconfig.get_config_var('EXT_SUFFIX'))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue