diff options
| author | Anderson Bravalheri <andersonbravalheri@gmail.com> | 2021-11-05 14:14:29 +0000 |
|---|---|---|
| committer | Anderson Bravalheri <andersonbravalheri@gmail.com> | 2021-11-05 14:14:29 +0000 |
| commit | e2220331136c3a60b8d70a6b4eaad05816c9b637 (patch) | |
| tree | 0bfaebe8c48a8645ee1fb897519f0d69241dcbc1 | |
| parent | f359b8a7608c7f118710af02cb5edab4e6abb942 (diff) | |
| download | python-setuptools-git-e2220331136c3a60b8d70a6b4eaad05816c9b637.tar.gz | |
Use warning instead of log for distutils command
As discussed in #2855, using an actual warning instead of the logger
allow users to control what gets displayed via warning filters.
| -rw-r--r-- | setuptools/command/egg_info.py | 5 | ||||
| -rw-r--r-- | setuptools/tests/test_sdist.py | 20 |
2 files changed, 7 insertions, 18 deletions
diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 8ae27d87..f2210292 100644 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -621,10 +621,11 @@ class manifest_maker(sdist): if hasattr(build_py, 'get_data_files_without_manifest'): return build_py.get_data_files_without_manifest() - log.warn( + warnings.warn( "Custom 'build_py' does not implement " "'get_data_files_without_manifest'.\nPlease extend command classes" - " from setuptools instead of distutils." + " from setuptools instead of distutils.", + SetuptoolsDeprecationWarning ) return build_py.get_data_files() diff --git a/setuptools/tests/test_sdist.py b/setuptools/tests/test_sdist.py index e6d8e908..66f46ad0 100644 --- a/setuptools/tests/test_sdist.py +++ b/setuptools/tests/test_sdist.py @@ -11,6 +11,7 @@ from unittest import mock import pytest import pkg_resources +from setuptools import SetuptoolsDeprecationWarning from setuptools.command.sdist import sdist from setuptools.command.egg_info import manifest_maker from setuptools.dist import Distribution @@ -148,8 +149,7 @@ class TestSdistTest: self.assert_package_data_in_manifest(cmd) - @mock.patch('setuptools.command.egg_info.log') - def test_custom_build_py(self, log_stub): + def test_custom_build_py(self): """ Ensure projects defining custom build_py don't break when creating sdists (issue #2849) @@ -180,25 +180,13 @@ class TestSdistTest: cmd.distribution.cmdclass = {'build_py': CustomBuildPy} assert cmd.distribution.get_command_class('build_py') == CustomBuildPy - with quiet(): + msg = "setuptools instead of distutils" + with quiet(), pytest.warns(SetuptoolsDeprecationWarning, match=msg): cmd.run() using_custom_command_guard.assert_called() self.assert_package_data_in_manifest(cmd) - warn_stub = log_stub.warn - warn_stub.assert_called() - for call in warn_stub.call_args_list: - args, _kw = call - if "setuptools instead of distutils" in args[0]: - return - else: - raise AssertionError( - "The user should have been warned to extend setuptools command" - " classes instead of distutils", - warn_stub.call_args_list - ) - def test_setup_py_exists(self): dist = Distribution(SETUP_ATTRS) dist.script_name = 'foo.py' |
