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
+92 -92
View File
@@ -12,9 +12,9 @@ from cibuildwheel.util import BuildSelector
def test_output_dir(platform, intercepted_build_args, monkeypatch):
OUTPUT_DIR = Path('some_output_dir')
OUTPUT_DIR = Path("some_output_dir")
monkeypatch.setenv('CIBW_OUTPUT_DIR', str(OUTPUT_DIR))
monkeypatch.setenv("CIBW_OUTPUT_DIR", str(OUTPUT_DIR))
main()
@@ -24,16 +24,16 @@ def test_output_dir(platform, intercepted_build_args, monkeypatch):
def test_output_dir_default(platform, intercepted_build_args, monkeypatch):
main()
assert intercepted_build_args.args[0].output_dir == Path('wheelhouse')
assert intercepted_build_args.args[0].output_dir == Path("wheelhouse")
@pytest.mark.parametrize('also_set_environment', [False, True])
@pytest.mark.parametrize("also_set_environment", [False, True])
def test_output_dir_argument(also_set_environment, platform, intercepted_build_args, monkeypatch):
OUTPUT_DIR = Path('some_output_dir')
OUTPUT_DIR = Path("some_output_dir")
monkeypatch.setattr(sys, 'argv', sys.argv + ['--output-dir', str(OUTPUT_DIR)])
monkeypatch.setattr(sys, "argv", sys.argv + ["--output-dir", str(OUTPUT_DIR)])
if also_set_environment:
monkeypatch.setenv('CIBW_OUTPUT_DIR', 'not_this_output_dir')
monkeypatch.setenv("CIBW_OUTPUT_DIR", "not_this_output_dir")
main()
@@ -41,24 +41,24 @@ def test_output_dir_argument(also_set_environment, platform, intercepted_build_a
def test_build_selector(platform, intercepted_build_args, monkeypatch, allow_empty):
BUILD = 'some build* *-selector'
SKIP = 'some skip* *-selector'
BUILD = "some build* *-selector"
SKIP = "some skip* *-selector"
monkeypatch.setenv('CIBW_BUILD', BUILD)
monkeypatch.setenv('CIBW_SKIP', SKIP)
monkeypatch.setenv("CIBW_BUILD", BUILD)
monkeypatch.setenv("CIBW_SKIP", SKIP)
main()
intercepted_build_selector = intercepted_build_args.args[0].build_selector
assert isinstance(intercepted_build_selector, BuildSelector)
assert intercepted_build_selector('build24-this')
assert not intercepted_build_selector('skip65-that')
assert intercepted_build_selector("build24-this")
assert not intercepted_build_selector("skip65-that")
# This unit test is just testing the options of 'main'
# Unit tests for BuildSelector are in build_selector_test.py
def test_empty_selector(platform, intercepted_build_args, monkeypatch):
monkeypatch.setenv('CIBW_SKIP', '*')
monkeypatch.setenv("CIBW_SKIP", "*")
with pytest.raises(SystemExit) as e:
main()
@@ -67,63 +67,63 @@ def test_empty_selector(platform, intercepted_build_args, monkeypatch):
@pytest.mark.parametrize(
'architecture, image, full_image',
"architecture, image, full_image",
[
('x86_64', None, 'quay.io/pypa/manylinux2010_x86_64:*'),
('x86_64', 'manylinux1', 'quay.io/pypa/manylinux1_x86_64:*'),
('x86_64', 'manylinux2010', 'quay.io/pypa/manylinux2010_x86_64:*'),
('x86_64', 'manylinux2014', 'quay.io/pypa/manylinux2014_x86_64:*'),
('x86_64', 'manylinux_2_24', 'quay.io/pypa/manylinux_2_24_x86_64:*'),
('x86_64', 'custom_image', 'custom_image'),
('i686', None, 'quay.io/pypa/manylinux2010_i686:*'),
('i686', 'manylinux1', 'quay.io/pypa/manylinux1_i686:*'),
('i686', 'manylinux2010', 'quay.io/pypa/manylinux2010_i686:*'),
('i686', 'manylinux2014', 'quay.io/pypa/manylinux2014_i686:*'),
('i686', 'manylinux_2_24', 'quay.io/pypa/manylinux_2_24_i686:*'),
('i686', 'custom_image', 'custom_image'),
('pypy_x86_64', None, 'pypywheels/manylinux2010-pypy_x86_64:*'),
('pypy_x86_64', 'manylinux1', 'manylinux1'), # Does not exist
('pypy_x86_64', 'manylinux2010', 'pypywheels/manylinux2010-pypy_x86_64:*'),
('pypy_x86_64', 'manylinux2014', 'manylinux2014'), # Does not exist (yet)
('pypy_x86_64', 'custom_image', 'custom_image'),
("x86_64", None, "quay.io/pypa/manylinux2010_x86_64:*"),
("x86_64", "manylinux1", "quay.io/pypa/manylinux1_x86_64:*"),
("x86_64", "manylinux2010", "quay.io/pypa/manylinux2010_x86_64:*"),
("x86_64", "manylinux2014", "quay.io/pypa/manylinux2014_x86_64:*"),
("x86_64", "manylinux_2_24", "quay.io/pypa/manylinux_2_24_x86_64:*"),
("x86_64", "custom_image", "custom_image"),
("i686", None, "quay.io/pypa/manylinux2010_i686:*"),
("i686", "manylinux1", "quay.io/pypa/manylinux1_i686:*"),
("i686", "manylinux2010", "quay.io/pypa/manylinux2010_i686:*"),
("i686", "manylinux2014", "quay.io/pypa/manylinux2014_i686:*"),
("i686", "manylinux_2_24", "quay.io/pypa/manylinux_2_24_i686:*"),
("i686", "custom_image", "custom_image"),
("pypy_x86_64", None, "pypywheels/manylinux2010-pypy_x86_64:*"),
("pypy_x86_64", "manylinux1", "manylinux1"), # Does not exist
("pypy_x86_64", "manylinux2010", "pypywheels/manylinux2010-pypy_x86_64:*"),
("pypy_x86_64", "manylinux2014", "manylinux2014"), # Does not exist (yet)
("pypy_x86_64", "custom_image", "custom_image"),
],
)
def test_manylinux_images(
architecture, image, full_image, platform, intercepted_build_args, monkeypatch
):
if image is not None:
monkeypatch.setenv('CIBW_MANYLINUX_' + architecture.upper() + '_IMAGE', image)
monkeypatch.setenv("CIBW_MANYLINUX_" + architecture.upper() + "_IMAGE", image)
main()
if platform == 'linux':
if platform == "linux":
assert fnmatch(intercepted_build_args.args[0].manylinux_images[architecture], full_image)
else:
assert intercepted_build_args.args[0].manylinux_images is None
def get_default_repair_command(platform):
if platform == 'linux':
return 'auditwheel repair -w {dest_dir} {wheel}'
elif platform == 'macos':
return 'delocate-listdeps {wheel} && delocate-wheel --require-archs {delocate_archs} -w {dest_dir} {wheel}'
elif platform == 'windows':
return ''
if platform == "linux":
return "auditwheel repair -w {dest_dir} {wheel}"
elif platform == "macos":
return "delocate-listdeps {wheel} && delocate-wheel --require-archs {delocate_archs} -w {dest_dir} {wheel}"
elif platform == "windows":
return ""
else:
raise ValueError('Unknown platform', platform)
raise ValueError("Unknown platform", platform)
@pytest.mark.parametrize('repair_command', [None, 'repair', 'repair -w {dest_dir} {wheel}'])
@pytest.mark.parametrize('platform_specific', [False, True])
@pytest.mark.parametrize("repair_command", [None, "repair", "repair -w {dest_dir} {wheel}"])
@pytest.mark.parametrize("platform_specific", [False, True])
def test_repair_command(
repair_command, platform_specific, platform, intercepted_build_args, monkeypatch
):
if repair_command is not None:
if platform_specific:
monkeypatch.setenv('CIBW_REPAIR_WHEEL_COMMAND_' + platform.upper(), repair_command)
monkeypatch.setenv('CIBW_REPAIR_WHEEL_COMMAND', 'overwritten')
monkeypatch.setenv("CIBW_REPAIR_WHEEL_COMMAND_" + platform.upper(), repair_command)
monkeypatch.setenv("CIBW_REPAIR_WHEEL_COMMAND", "overwritten")
else:
monkeypatch.setenv('CIBW_REPAIR_WHEEL_COMMAND', repair_command)
monkeypatch.setenv("CIBW_REPAIR_WHEEL_COMMAND", repair_command)
main()
@@ -132,17 +132,17 @@ def test_repair_command(
@pytest.mark.parametrize(
'environment',
[{}, {'something': 'value'}, {'something': 'value', 'something_else': 'other_value'}],
"environment",
[{}, {"something": "value"}, {"something": "value", "something_else": "other_value"}],
)
@pytest.mark.parametrize('platform_specific', [False, True])
@pytest.mark.parametrize("platform_specific", [False, True])
def test_environment(environment, platform_specific, platform, intercepted_build_args, monkeypatch):
env_string = ' '.join(f'{k}={v}' for k, v in environment.items())
env_string = " ".join(f"{k}={v}" for k, v in environment.items())
if platform_specific:
monkeypatch.setenv('CIBW_ENVIRONMENT_' + platform.upper(), env_string)
monkeypatch.setenv('CIBW_ENVIRONMENT', 'overwritten')
monkeypatch.setenv("CIBW_ENVIRONMENT_" + platform.upper(), env_string)
monkeypatch.setenv("CIBW_ENVIRONMENT", "overwritten")
else:
monkeypatch.setenv('CIBW_ENVIRONMENT', env_string)
monkeypatch.setenv("CIBW_ENVIRONMENT", env_string)
main()
@@ -151,85 +151,85 @@ def test_environment(environment, platform_specific, platform, intercepted_build
assert intercepted_environment.as_dictionary(prev_environment={}) == environment
@pytest.mark.parametrize('test_requires', [None, 'requirement other_requirement'])
@pytest.mark.parametrize('platform_specific', [False, True])
@pytest.mark.parametrize("test_requires", [None, "requirement other_requirement"])
@pytest.mark.parametrize("platform_specific", [False, True])
def test_test_requires(
test_requires, platform_specific, platform, intercepted_build_args, monkeypatch
):
if test_requires is not None:
if platform_specific:
monkeypatch.setenv('CIBW_TEST_REQUIRES_' + platform.upper(), test_requires)
monkeypatch.setenv('CIBW_TEST_REQUIRES', 'overwritten')
monkeypatch.setenv("CIBW_TEST_REQUIRES_" + platform.upper(), test_requires)
monkeypatch.setenv("CIBW_TEST_REQUIRES", "overwritten")
else:
monkeypatch.setenv('CIBW_TEST_REQUIRES', test_requires)
monkeypatch.setenv("CIBW_TEST_REQUIRES", test_requires)
main()
assert intercepted_build_args.args[0].test_requires == (test_requires or '').split()
assert intercepted_build_args.args[0].test_requires == (test_requires or "").split()
@pytest.mark.parametrize('test_extras', [None, 'extras'])
@pytest.mark.parametrize('platform_specific', [False, True])
@pytest.mark.parametrize("test_extras", [None, "extras"])
@pytest.mark.parametrize("platform_specific", [False, True])
def test_test_extras(test_extras, platform_specific, platform, intercepted_build_args, monkeypatch):
if test_extras is not None:
if platform_specific:
monkeypatch.setenv('CIBW_TEST_EXTRAS_' + platform.upper(), test_extras)
monkeypatch.setenv('CIBW_TEST_EXTRAS', 'overwritten')
monkeypatch.setenv("CIBW_TEST_EXTRAS_" + platform.upper(), test_extras)
monkeypatch.setenv("CIBW_TEST_EXTRAS", "overwritten")
else:
monkeypatch.setenv('CIBW_TEST_EXTRAS', test_extras)
monkeypatch.setenv("CIBW_TEST_EXTRAS", test_extras)
main()
assert intercepted_build_args.args[0].test_extras == (
'[' + test_extras + ']' if test_extras else ''
"[" + test_extras + "]" if test_extras else ""
)
@pytest.mark.parametrize('test_command', [None, 'test --command'])
@pytest.mark.parametrize('platform_specific', [False, True])
@pytest.mark.parametrize("test_command", [None, "test --command"])
@pytest.mark.parametrize("platform_specific", [False, True])
def test_test_command(
test_command, platform_specific, platform, intercepted_build_args, monkeypatch
):
if test_command is not None:
if platform_specific:
monkeypatch.setenv('CIBW_TEST_COMMAND_' + platform.upper(), test_command)
monkeypatch.setenv('CIBW_TEST_COMMAND', 'overwritten')
monkeypatch.setenv("CIBW_TEST_COMMAND_" + platform.upper(), test_command)
monkeypatch.setenv("CIBW_TEST_COMMAND", "overwritten")
else:
monkeypatch.setenv('CIBW_TEST_COMMAND', test_command)
monkeypatch.setenv("CIBW_TEST_COMMAND", test_command)
main()
assert intercepted_build_args.args[0].test_command == test_command
@pytest.mark.parametrize('before_build', [None, 'before --build'])
@pytest.mark.parametrize('platform_specific', [False, True])
@pytest.mark.parametrize("before_build", [None, "before --build"])
@pytest.mark.parametrize("platform_specific", [False, True])
def test_before_build(
before_build, platform_specific, platform, intercepted_build_args, monkeypatch
):
if before_build is not None:
if platform_specific:
monkeypatch.setenv('CIBW_BEFORE_BUILD_' + platform.upper(), before_build)
monkeypatch.setenv('CIBW_BEFORE_BUILD', 'overwritten')
monkeypatch.setenv("CIBW_BEFORE_BUILD_" + platform.upper(), before_build)
monkeypatch.setenv("CIBW_BEFORE_BUILD", "overwritten")
else:
monkeypatch.setenv('CIBW_BEFORE_BUILD', before_build)
monkeypatch.setenv("CIBW_BEFORE_BUILD", before_build)
main()
assert intercepted_build_args.args[0].before_build == before_build
@pytest.mark.parametrize('build_verbosity', [None, 0, 2, -2, 4, -4])
@pytest.mark.parametrize('platform_specific', [False, True])
@pytest.mark.parametrize("build_verbosity", [None, 0, 2, -2, 4, -4])
@pytest.mark.parametrize("platform_specific", [False, True])
def test_build_verbosity(
build_verbosity, platform_specific, platform, intercepted_build_args, monkeypatch
):
if build_verbosity is not None:
if platform_specific:
monkeypatch.setenv('CIBW_BUILD_VERBOSITY_' + platform.upper(), str(build_verbosity))
monkeypatch.setenv('CIBW_BUILD_VERBOSITY', 'overwritten')
monkeypatch.setenv("CIBW_BUILD_VERBOSITY_" + platform.upper(), str(build_verbosity))
monkeypatch.setenv("CIBW_BUILD_VERBOSITY", "overwritten")
else:
monkeypatch.setenv('CIBW_BUILD_VERBOSITY', str(build_verbosity))
monkeypatch.setenv("CIBW_BUILD_VERBOSITY", str(build_verbosity))
main()
@@ -237,14 +237,14 @@ def test_build_verbosity(
assert intercepted_build_args.args[0].build_verbosity == expected_verbosity
@pytest.mark.parametrize('option_name', ['CIBW_BUILD', 'CIBW_SKIP'])
@pytest.mark.parametrize("option_name", ["CIBW_BUILD", "CIBW_SKIP"])
@pytest.mark.parametrize(
'option_value, build_selector_patterns',
"option_value, build_selector_patterns",
[
('*-manylinux1_*', ['*-manylinux_*']),
('*-macosx_10_6_intel', ['*-macosx_x86_64']),
('*-macosx_10_9_x86_64', ['*-macosx_x86_64']),
('cp37-macosx_10_9_x86_64', ['cp37-macosx_x86_64']),
("*-manylinux1_*", ["*-manylinux_*"]),
("*-macosx_10_6_intel", ["*-macosx_x86_64"]),
("*-macosx_10_9_x86_64", ["*-macosx_x86_64"]),
("cp37-macosx_10_9_x86_64", ["cp37-macosx_x86_64"]),
],
)
def test_build_selector_migrations(
@@ -262,21 +262,21 @@ def test_build_selector_migrations(
intercepted_build_selector = intercepted_build_args.args[0].build_selector
assert isinstance(intercepted_build_selector, BuildSelector)
if option_name == 'CIBW_BUILD':
if option_name == "CIBW_BUILD":
assert intercepted_build_selector.build_patterns == build_selector_patterns
else:
assert intercepted_build_selector.skip_patterns == build_selector_patterns
@pytest.mark.parametrize('before_all', ["", None, 'test text'])
@pytest.mark.parametrize('platform_specific', [False, True])
@pytest.mark.parametrize("before_all", ["", None, "test text"])
@pytest.mark.parametrize("platform_specific", [False, True])
def test_before_all(before_all, platform_specific, platform, intercepted_build_args, monkeypatch):
if before_all is not None:
if platform_specific:
monkeypatch.setenv('CIBW_BEFORE_ALL_' + platform.upper(), before_all)
monkeypatch.setenv('CIBW_BEFORE_ALL', 'overwritten')
monkeypatch.setenv("CIBW_BEFORE_ALL_" + platform.upper(), before_all)
monkeypatch.setenv("CIBW_BEFORE_ALL", "overwritten")
else:
monkeypatch.setenv('CIBW_BEFORE_ALL', before_all)
monkeypatch.setenv("CIBW_BEFORE_ALL", before_all)
main()
+46 -46
View File
@@ -9,29 +9,29 @@ from .conftest import MOCK_PACKAGE_DIR
def test_unknown_platform_non_ci(monkeypatch, capsys):
monkeypatch.delenv('CI', raising=False)
monkeypatch.delenv('BITRISE_BUILD_NUMBER', raising=False)
monkeypatch.delenv('AZURE_HTTP_USER_AGENT', raising=False)
monkeypatch.delenv('TRAVIS', raising=False)
monkeypatch.delenv('APPVEYOR', raising=False)
monkeypatch.delenv('GITHUB_ACTIONS', raising=False)
monkeypatch.delenv('GITLAB_CI', raising=False)
monkeypatch.delenv('CIRCLECI', raising=False)
monkeypatch.delenv('CIBW_PLATFORM', raising=False)
monkeypatch.delenv("CI", raising=False)
monkeypatch.delenv("BITRISE_BUILD_NUMBER", raising=False)
monkeypatch.delenv("AZURE_HTTP_USER_AGENT", raising=False)
monkeypatch.delenv("TRAVIS", raising=False)
monkeypatch.delenv("APPVEYOR", raising=False)
monkeypatch.delenv("GITHUB_ACTIONS", raising=False)
monkeypatch.delenv("GITLAB_CI", raising=False)
monkeypatch.delenv("CIRCLECI", raising=False)
monkeypatch.delenv("CIBW_PLATFORM", raising=False)
with pytest.raises(SystemExit) as exit:
main()
assert exit.value.code == 2
_, err = capsys.readouterr()
assert 'cibuildwheel: Unable to detect platform.' in err
assert 'cibuildwheel should run on your CI server' in err
assert "cibuildwheel: Unable to detect platform." in err
assert "cibuildwheel should run on your CI server" in err
def test_unknown_platform_on_ci(monkeypatch, capsys):
monkeypatch.setenv('CI', 'true')
monkeypatch.setattr(sys, 'platform', 'nonexistent')
monkeypatch.delenv('CIBW_PLATFORM', raising=False)
monkeypatch.setenv("CI", "true")
monkeypatch.setattr(sys, "platform", "nonexistent")
monkeypatch.delenv("CIBW_PLATFORM", raising=False)
with pytest.raises(SystemExit) as exit:
main()
@@ -42,19 +42,19 @@ def test_unknown_platform_on_ci(monkeypatch, capsys):
def test_unknown_platform(monkeypatch, capsys):
monkeypatch.setenv('CIBW_PLATFORM', 'nonexistent')
monkeypatch.setenv("CIBW_PLATFORM", "nonexistent")
with pytest.raises(SystemExit) as exit:
main()
_, err = capsys.readouterr()
assert exit.value.code == 2
assert 'cibuildwheel: Unsupported platform: nonexistent' in err
assert "cibuildwheel: Unsupported platform: nonexistent" in err
def test_platform_argument(platform, intercepted_build_args, monkeypatch):
monkeypatch.setenv('CIBW_PLATFORM', 'nonexistent')
monkeypatch.setattr(sys, 'argv', sys.argv + ['--platform', platform])
monkeypatch.setenv("CIBW_PLATFORM", "nonexistent")
monkeypatch.setattr(sys, "argv", sys.argv + ["--platform", platform])
main()
@@ -72,24 +72,24 @@ def test_archs_default(platform, intercepted_build_args, monkeypatch):
main()
build_options = intercepted_build_args.args[0]
if platform == 'linux':
if platform == "linux":
assert build_options.architectures == {Architecture.x86_64, Architecture.i686}
elif platform == 'windows':
elif platform == "windows":
assert build_options.architectures == {Architecture.AMD64, Architecture.x86}
else:
assert build_options.architectures == {Architecture.x86_64}
@pytest.mark.parametrize('use_env_var', [False, True])
@pytest.mark.parametrize("use_env_var", [False, True])
def test_archs_argument(platform, intercepted_build_args, monkeypatch, use_env_var):
if use_env_var:
monkeypatch.setenv('CIBW_ARCHS', 'ppc64le')
monkeypatch.setenv("CIBW_ARCHS", "ppc64le")
else:
monkeypatch.setenv('CIBW_ARCHS', 'unused')
monkeypatch.setattr(sys, 'argv', sys.argv + ['--archs', 'ppc64le'])
monkeypatch.setenv("CIBW_ARCHS", "unused")
monkeypatch.setattr(sys, "argv", sys.argv + ["--archs", "ppc64le"])
if platform in {'macos', 'windows'}:
if platform in {"macos", "windows"}:
with pytest.raises(SystemExit) as exit:
main()
assert exit.value.args == (4,)
@@ -101,50 +101,50 @@ def test_archs_argument(platform, intercepted_build_args, monkeypatch, use_env_v
def test_archs_platform_specific(platform, intercepted_build_args, monkeypatch):
monkeypatch.setenv('CIBW_ARCHS', 'unused')
monkeypatch.setenv('CIBW_ARCHS_LINUX', 'ppc64le')
monkeypatch.setenv('CIBW_ARCHS_WINDOWS', 'x86')
monkeypatch.setenv('CIBW_ARCHS_MACOS', 'x86_64')
monkeypatch.setenv("CIBW_ARCHS", "unused")
monkeypatch.setenv("CIBW_ARCHS_LINUX", "ppc64le")
monkeypatch.setenv("CIBW_ARCHS_WINDOWS", "x86")
monkeypatch.setenv("CIBW_ARCHS_MACOS", "x86_64")
main()
build_options = intercepted_build_args.args[0]
if platform == 'linux':
if platform == "linux":
assert build_options.architectures == {Architecture.ppc64le}
elif platform == 'windows':
elif platform == "windows":
assert build_options.architectures == {Architecture.x86}
elif platform == 'macos':
elif platform == "macos":
assert build_options.architectures == {Architecture.x86_64}
def test_archs_platform_native(platform, intercepted_build_args, monkeypatch):
monkeypatch.setenv('CIBW_ARCHS', 'native')
monkeypatch.setenv("CIBW_ARCHS", "native")
main()
build_options = intercepted_build_args.args[0]
if platform in {'linux', 'macos'}:
if platform in {"linux", "macos"}:
assert build_options.architectures == {Architecture.x86_64}
elif platform == 'windows':
elif platform == "windows":
assert build_options.architectures == {Architecture.AMD64}
def test_archs_platform_auto64(platform, intercepted_build_args, monkeypatch):
monkeypatch.setenv('CIBW_ARCHS', 'auto64')
monkeypatch.setenv("CIBW_ARCHS", "auto64")
main()
build_options = intercepted_build_args.args[0]
if platform in {'linux', 'macos'}:
if platform in {"linux", "macos"}:
assert build_options.architectures == {Architecture.x86_64}
elif platform == 'windows':
elif platform == "windows":
assert build_options.architectures == {Architecture.AMD64}
def test_archs_platform_auto32(platform, intercepted_build_args, monkeypatch):
monkeypatch.setenv('CIBW_ARCHS', 'auto32')
monkeypatch.setenv("CIBW_ARCHS", "auto32")
if platform == 'macos':
if platform == "macos":
with pytest.raises(SystemExit) as exit:
main()
assert exit.value.args == (4,)
@@ -154,19 +154,19 @@ def test_archs_platform_auto32(platform, intercepted_build_args, monkeypatch):
build_options = intercepted_build_args.args[0]
if platform == 'linux':
if platform == "linux":
assert build_options.architectures == {Architecture.i686}
elif platform == 'windows':
elif platform == "windows":
assert build_options.architectures == {Architecture.x86}
def test_archs_platform_all(platform, intercepted_build_args, monkeypatch):
monkeypatch.setenv('CIBW_ARCHS', 'all')
monkeypatch.setenv("CIBW_ARCHS", "all")
main()
build_options = intercepted_build_args.args[0]
if platform == 'linux':
if platform == "linux":
assert build_options.architectures == {
Architecture.x86_64,
Architecture.i686,
@@ -174,9 +174,9 @@ def test_archs_platform_all(platform, intercepted_build_args, monkeypatch):
Architecture.ppc64le,
Architecture.s390x,
}
elif platform == 'windows':
elif platform == "windows":
assert build_options.architectures == {Architecture.x86, Architecture.AMD64}
elif platform == 'macos':
elif platform == "macos":
assert build_options.architectures == {
Architecture.x86_64,
Architecture.arm64,
@@ -9,16 +9,16 @@ from cibuildwheel.__main__ import main
@pytest.fixture(autouse=True, scope="function")
def fake_package_dir(monkeypatch, tmp_path):
'''
"""
Set up a fake project
'''
"""
local_path = tmp_path / "tmp_project"
local_path.mkdir()
local_path.joinpath("setup.py").touch()
monkeypatch.setattr(sys, 'argv', ['cibuildwheel', str(local_path)])
monkeypatch.setattr(sys, "argv", ["cibuildwheel", str(local_path)])
return local_path
@@ -29,14 +29,14 @@ def test_no_override(platform, monkeypatch, intercepted_build_args):
intercepted_build_selector = intercepted_build_args.args[0].build_selector
assert intercepted_build_selector('cp39-win32')
assert intercepted_build_selector('cp36-win32')
assert intercepted_build_selector("cp39-win32")
assert intercepted_build_selector("cp36-win32")
assert intercepted_build_selector.requires_python is None
def test_override_env(platform, monkeypatch, intercepted_build_args):
monkeypatch.setenv('CIBW_PROJECT_REQUIRES_PYTHON', '>=3.8')
monkeypatch.setenv("CIBW_PROJECT_REQUIRES_PYTHON", ">=3.8")
main()
@@ -44,8 +44,8 @@ def test_override_env(platform, monkeypatch, intercepted_build_args):
assert intercepted_build_selector.requires_python == SpecifierSet(">=3.8")
assert intercepted_build_selector('cp39-win32')
assert not intercepted_build_selector('cp36-win32')
assert intercepted_build_selector("cp39-win32")
assert not intercepted_build_selector("cp36-win32")
def test_override_setup_cfg(platform, monkeypatch, intercepted_build_args, fake_package_dir):
@@ -65,8 +65,8 @@ def test_override_setup_cfg(platform, monkeypatch, intercepted_build_args, fake_
assert intercepted_build_selector.requires_python == SpecifierSet(">=3.8")
assert intercepted_build_selector('cp39-win32')
assert not intercepted_build_selector('cp36-win32')
assert intercepted_build_selector("cp39-win32")
assert not intercepted_build_selector("cp36-win32")
def test_override_pyproject_toml(platform, monkeypatch, intercepted_build_args, fake_package_dir):
@@ -86,8 +86,8 @@ def test_override_pyproject_toml(platform, monkeypatch, intercepted_build_args,
assert intercepted_build_selector.requires_python == SpecifierSet(">=3.8")
assert intercepted_build_selector('cp39-win32')
assert not intercepted_build_selector('cp36-win32')
assert intercepted_build_selector("cp39-win32")
assert not intercepted_build_selector("cp36-win32")
def test_override_setup_py_simple(platform, monkeypatch, intercepted_build_args, fake_package_dir):
@@ -111,5 +111,5 @@ def test_override_setup_py_simple(platform, monkeypatch, intercepted_build_args,
assert intercepted_build_selector.requires_python == SpecifierSet(">=3.7")
assert intercepted_build_selector('cp39-win32')
assert not intercepted_build_selector('cp36-win32')
assert intercepted_build_selector("cp39-win32")
assert not intercepted_build_selector("cp36-win32")