def is_python_build(check_home=None):
if check_home is not None:
import warnings
- warnings.warn("check_home argument is deprecated and ignored.",
- DeprecationWarning, stacklevel=2)
+ warnings.warn(
+ (
+ 'The check_home argument of sysconfig.is_python_build is '
+ 'deprecated and its value is ignored. '
+ 'It will be removed in Python 3.15.'
+ ),
+ DeprecationWarning,
+ stacklevel=2,
+ )
for fn in ("Setup", "Setup.local"):
if os.path.isfile(os.path.join(_PROJECT_BASE, "Modules", fn)):
return True
class DeprecationTests(unittest.TestCase):
- def deprecated(self, removal_version, deprecation_msg=None, attribute_msg=None):
+ def deprecated(self, removal_version, deprecation_msg=None, error=Exception, error_msg=None):
if sys.version_info >= removal_version:
- return self.assertRaises(AttributeError, msg=attribute_msg)
+ return self.assertRaises(error, msg=error_msg)
else:
return self.assertWarns(DeprecationWarning, msg=deprecation_msg)
'sysconfig.expand_makefile_vars is deprecated and will be removed in '
'Python 3.16. Use sysconfig.get_paths(vars=...) instead.',
),
- attribute_msg="module 'sysconfig' has no attribute 'expand_makefile_vars'",
+ error=AttributeError,
+ error_msg="module 'sysconfig' has no attribute 'expand_makefile_vars'",
):
sysconfig.expand_makefile_vars('', {})
+ def test_is_python_build_check_home(self):
+ with self.deprecated(
+ removal_version=(3, 15),
+ deprecation_msg=(
+ 'The check_home argument of sysconfig.is_python_build is '
+ 'deprecated and its value is ignored. '
+ 'It will be removed in Python 3.15.'
+ ),
+ error=TypeError,
+ error_msg="is_python_build() takes 0 positional arguments but 1 were given",
+ ):
+ sysconfig.is_python_build('foo')
+
if __name__ == "__main__":
unittest.main()