diff --git a/CHANGELOG.md b/CHANGELOG.md index b2a9d89..2e4bddb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ #### Date TBD * Use forkserver start method for multiprocessing by @eltoder in https://github.com/CleanCut/green/pull/296 +* Adjust to breaking changes in `setuptools` 72.0.0 # Version 4.0.2 #### 18 Apr 2024 diff --git a/Makefile b/Makefile index df4db2d..5f19931 100644 --- a/Makefile +++ b/Makefile @@ -21,10 +21,16 @@ super-clean: super-clean-message clean-silent @rm -rf venv* -test: test-versions test-installed test-coverage +test: test-mypy test-black test-versions test-installed test-coverage @# test-coverage needs to be last in deps, don't clean after it runs! @echo "\n(test) completed\n" +test-mypy: + mypy green example + +test-black: + black --check --diff green example + test-local: @pip3 install --upgrade -e '.[dev]' @make test-installed diff --git a/green/command.py b/green/command.py index f510a1a..da74f9f 100644 --- a/green/command.py +++ b/green/command.py @@ -62,11 +62,22 @@ def run(self) -> None: if self.distribution.install_requires: self.distribution.fetch_build_eggs(self.distribution.install_requires) - if self.distribution.tests_require: + + # TODO: Remove this once setuptools >= 72.0.0 is ubiquitous, since it no longer supports the + # "test" subcommand + if ( + hasattr(self.distribution, "tests_require") + and self.distribution.tests_require + ): self.distribution.fetch_build_eggs(self.distribution.tests_require) + # TODO: Remove this once setuptools >= 72.0.0 is ubiquitous, since it no longer supports the + # "test" subcommand script_args = self.distribution.script_args[1:] - if self.distribution.test_suite is not None: + if ( + hasattr(self.distribution, "test_suite") + and self.distribution.test_suite is not None + ): script_args.append(self.distribution.test_suite) error_code = main(script_args) diff --git a/green/process.py b/green/process.py index febf2c1..130b129 100644 --- a/green/process.py +++ b/green/process.py @@ -64,8 +64,8 @@ def ddebug(msg: str, err: ExcInfoType | None = None) -> None: # pragma: no cove error_string = "".join(traceback.format_exception(*err)) else: error_string = "" - sys.__stdout__.write(f"({os.getpid()}) {msg} {error_string}\n") - sys.__stdout__.flush() + sys.__stdout__.write(f"({os.getpid()}) {msg} {error_string}\n") # type: ignore + sys.__stdout__.flush() # type: ignore class ProcessLogger: diff --git a/green/test/test_command.py b/green/test/test_command.py index 5130520..eec8c96 100644 --- a/green/test/test_command.py +++ b/green/test/test_command.py @@ -93,20 +93,6 @@ def test_initialize_options(self): for attr in ["completion_file", "clear_omit", "debug", "processes"]: self.assertTrue(hasattr(cmd, attr), attr) - @patch("green.command.main", return_value=0) - def test_run(self, main): - d = Distribution( - { - "script_name": "setup.py", - "script_args": ["green"], - "test_suite": "green.test.test_version", - } - ) - - cmd = command.green(d) - cmd.run() - main.assert_called_once_with(["green.test.test_version"]) - @patch("green.command.main", return_value=125) def test_run_exits(self, main): d = Distribution({"script_name": "setup.py", "script_args": ["green"]}) @@ -115,24 +101,3 @@ def test_run_exits(self, main): with self.assertRaises(SystemExit) as se: cmd.run() self.assertEqual(se.exception.code, 125) - - @patch("green.command.main", return_value=0) - def test_requires(self, main): - d = Distribution( - { - "script_name": "setup.py", - "script_args": ["green"], - "install_requires": ["six"], - "tests_require": ["mock", "unittest2"], - } - ) - d.fetch_build_eggs = MagicMock() - cmd = command.green(d) - cmd.run() - - d.fetch_build_eggs.assert_has_calls( - [ - call(["six"]), - call(["mock", "unittest2"]), - ] - ) diff --git a/test_versions b/test_versions index 4c13b3b..9e9197c 100755 --- a/test_versions +++ b/test_versions @@ -73,13 +73,8 @@ for PYTHON_VERSION in ${PYTHON_VERSIONS} ; do exit 7 fi hash -r - REQUIREMENTS_FILE="requirements-optional.txt" - if [ "${PYTHON}" == "pypy3" ] ; then - # `black` depends on `typed_ast` which isn't supported by pypy3. We can remove this once - # `black` starts depending on built-in `ast` - REQUIREMENTS_FILE="requirements.txt" - fi - ${VENV_DIR}/bin/pip install -r requirements-optional.txt | grep -Ev "Requirement already|however version|consider upgrading" + ${VENV_DIR}/bin/pip install -r requirements.txt | grep -Ev "Requirement already|however version|consider upgrading" + ${VENV_DIR}/bin/pip install -r requirements-dev.txt | grep -Ev "Requirement already|however version|consider upgrading" deactivate done