style: activate string normalization

This commit is contained in:
Henry Schreiner
2021-05-03 13:12:36 -04:00
committed by Henry Schreiner
parent d1900f6a05
commit bda76b21cb
54 changed files with 1598 additions and 1599 deletions
+31 -31
View File
@@ -15,15 +15,15 @@ class ArgsInterceptor:
self.kwargs = kwargs
MOCK_PACKAGE_DIR = Path('some_package_dir')
MOCK_PACKAGE_DIR = Path("some_package_dir")
@pytest.fixture(autouse=True)
def mock_protection(monkeypatch):
'''
"""
Ensure that a unit test will never actually run a cibuildwheel 'build'
function, which shouldn't be run on a developer's machine
'''
"""
def fail_on_call(*args, **kwargs):
raise RuntimeError("This should never be called")
@@ -31,31 +31,31 @@ def mock_protection(monkeypatch):
def ignore_call(*args, **kwargs):
pass
monkeypatch.setattr(subprocess, 'Popen', fail_on_call)
monkeypatch.setattr(util, 'download', fail_on_call)
monkeypatch.setattr(windows, 'build', fail_on_call)
monkeypatch.setattr(linux, 'build', fail_on_call)
monkeypatch.setattr(macos, 'build', fail_on_call)
monkeypatch.setattr(subprocess, "Popen", fail_on_call)
monkeypatch.setattr(util, "download", fail_on_call)
monkeypatch.setattr(windows, "build", fail_on_call)
monkeypatch.setattr(linux, "build", fail_on_call)
monkeypatch.setattr(macos, "build", fail_on_call)
monkeypatch.setattr(Path, 'mkdir', ignore_call)
monkeypatch.setattr(Path, "mkdir", ignore_call)
@pytest.fixture(autouse=True)
def fake_package_dir(monkeypatch):
'''
"""
Monkey-patch enough for the main() function to run
'''
"""
real_path_exists = Path.exists
def mock_path_exists(path):
if path == MOCK_PACKAGE_DIR / 'setup.py':
if path == MOCK_PACKAGE_DIR / "setup.py":
return True
else:
return real_path_exists(path)
args = ['cibuildwheel', str(MOCK_PACKAGE_DIR)]
monkeypatch.setattr(Path, 'exists', mock_path_exists)
monkeypatch.setattr(sys, 'argv', args)
args = ["cibuildwheel", str(MOCK_PACKAGE_DIR)]
monkeypatch.setattr(Path, "exists", mock_path_exists)
monkeypatch.setattr(sys, "argv", args)
return args
@@ -65,26 +65,26 @@ def disable_print_wheels(monkeypatch):
def empty_cm(*args, **kwargs):
yield
monkeypatch.setattr(util, 'print_new_wheels', empty_cm)
monkeypatch.setattr(util, "print_new_wheels", empty_cm)
@pytest.fixture
def allow_empty(request, monkeypatch, fake_package_dir):
monkeypatch.setattr(sys, 'argv', fake_package_dir + ['--allow-empty'])
monkeypatch.setattr(sys, "argv", fake_package_dir + ["--allow-empty"])
@pytest.fixture(params=['linux', 'macos', 'windows'])
@pytest.fixture(params=["linux", "macos", "windows"])
def platform(request, monkeypatch):
platform_value = request.param
monkeypatch.setenv('CIBW_PLATFORM', platform_value)
monkeypatch.setenv("CIBW_PLATFORM", platform_value)
if platform_value == 'windows':
monkeypatch.setattr(platform_module, 'machine', lambda: 'AMD64')
if platform_value == "windows":
monkeypatch.setattr(platform_module, "machine", lambda: "AMD64")
else:
monkeypatch.setattr(platform_module, 'machine', lambda: 'x86_64')
monkeypatch.setattr(platform_module, "machine", lambda: "x86_64")
if platform_value == 'macos':
monkeypatch.setattr(macos, 'get_macos_version', lambda: (11, 1))
if platform_value == "macos":
monkeypatch.setattr(macos, "get_macos_version", lambda: (11, 1))
return platform_value
@@ -93,13 +93,13 @@ def platform(request, monkeypatch):
def intercepted_build_args(platform, monkeypatch):
intercepted = ArgsInterceptor()
if platform == 'linux':
monkeypatch.setattr(linux, 'build', intercepted)
elif platform == 'macos':
monkeypatch.setattr(macos, 'build', intercepted)
elif platform == 'windows':
monkeypatch.setattr(windows, 'build', intercepted)
if platform == "linux":
monkeypatch.setattr(linux, "build", intercepted)
elif platform == "macos":
monkeypatch.setattr(macos, "build", intercepted)
elif platform == "windows":
monkeypatch.setattr(windows, "build", intercepted)
else:
raise ValueError(f'unknown platform value: {platform}')
raise ValueError(f"unknown platform value: {platform}")
return intercepted