def test_run(format_mock: mock.Mock, build_mock: mock.Mock): """Ensure both format and normal build are called in sequence.""" dist = Distribution() # Simulate setup.py registration dist.cmdclass = { "format": setuptools_black.setuptools_command.FormatCommand, } build_command = BuildCommand(dist) build_command.run() # Format run once, in check-only mode format_mock.return_value.run.assert_called_once_with() assert format_mock.return_value.check is True # Build run once, in check-only mode build_mock.run.assert_called_once_with(build_command)