diff --git a/cibuildwheel/__main__.py b/cibuildwheel/__main__.py index 2d309788..b3aaacf2 100644 --- a/cibuildwheel/__main__.py +++ b/cibuildwheel/__main__.py @@ -12,7 +12,10 @@ from cibuildwheel.environment import ( EnvironmentParseError, parse_environment, ) -from cibuildwheel.util import BuildSelector, Unbuffered +from cibuildwheel.util import ( + BuildSelector, + Unbuffered +) def get_option_from_environment(option_name, platform=None, default=None): diff --git a/cibuildwheel/bashlex_eval.py b/cibuildwheel/bashlex_eval.py index 7e2d7f4a..8e2c0831 100644 --- a/cibuildwheel/bashlex_eval.py +++ b/cibuildwheel/bashlex_eval.py @@ -1,6 +1,5 @@ import shlex import subprocess -import sys from collections import namedtuple import bashlex @@ -67,6 +66,5 @@ def evaluate_command_node(node, context): return subprocess.check_output(shlex.split(command), env=context.environment, universal_newlines=True) - def evaluate_parameter_node(node, context): return context.environment.get(node.value, '') diff --git a/docs/mkdocs_include_markdown_plugin/mkdocs_include_markdown_plugin/plugin.py b/docs/mkdocs_include_markdown_plugin/mkdocs_include_markdown_plugin/plugin.py index 2f43d0f3..b6b7a723 100644 --- a/docs/mkdocs_include_markdown_plugin/mkdocs_include_markdown_plugin/plugin.py +++ b/docs/mkdocs_include_markdown_plugin/mkdocs_include_markdown_plugin/plugin.py @@ -55,7 +55,6 @@ class ImportMarkdownPlugin(mkdocs.plugins.BasePlugin): return text_to_include - def found_includemarkdown_tag(match): filename = match.group('filename') start = match.group('start') diff --git a/test/10_cpp_standards/cibuildwheel_test.py b/test/10_cpp_standards/cibuildwheel_test.py index 2fc172e0..9b2cb724 100644 --- a/test/10_cpp_standards/cibuildwheel_test.py +++ b/test/10_cpp_standards/cibuildwheel_test.py @@ -1,13 +1,12 @@ import os -import sys import pytest import utils - project_dir = os.path.dirname(__file__) + def test_cpp11(tmp_path): # This test checks that the C++11 standard is supported @@ -18,8 +17,8 @@ def test_cpp11(tmp_path): actual_wheels = utils.cibuildwheel_run(project_dir, add_env=add_env) expected_wheels = [x for x in utils.expected_wheels( - 'spam', '0.1.0', macosx_deployment_target='10.9') - if 'cp27-cp27m-win' not in x] + 'spam', '0.1.0', macosx_deployment_target='10.9') + if 'cp27-cp27m-win' not in x] assert set(actual_wheels) == set(expected_wheels) @@ -35,15 +34,15 @@ def test_cpp14(): actual_wheels = utils.cibuildwheel_run(project_dir, add_env=add_env) expected_wheels = [x for x in utils.expected_wheels( - 'spam', '0.1.0', macosx_deployment_target='10.9') - if 'cp27-cp27m-win' not in x and 'cp35-cp35m-win' not in x] + 'spam', '0.1.0', macosx_deployment_target='10.9') + if 'cp27-cp27m-win' not in x and 'cp35-cp35m-win' not in x] assert set(actual_wheels) == set(expected_wheels) def test_cpp17(): # This test checks that the C++17 standard is supported - # Python 2.7 uses the `register` keyword which is forbidden in the C++17 standard + # Python 2.7 uses the `register` keyword which is forbidden in the C++17 standard # The manylinux1 docker image does not have a compiler which supports C++11 # Python 3.4 and 3.5 are compiled with MSVC 10, which does not support C++17 if os.environ.get('APPVEYOR_BUILD_WORKER_IMAGE', '') == 'Visual Studio 2015': @@ -55,6 +54,6 @@ def test_cpp17(): actual_wheels = utils.cibuildwheel_run(project_dir, add_env=add_env) expected_wheels = [x for x in utils.expected_wheels( - 'spam', '0.1.0', macosx_deployment_target='10.13') - if 'cp27-cp27m-win' not in x and 'cp35-cp35m-win' not in x] + 'spam', '0.1.0', macosx_deployment_target='10.13') + if 'cp27-cp27m-win' not in x and 'cp35-cp35m-win' not in x] assert set(actual_wheels) == set(expected_wheels) diff --git a/test/10_cpp_standards/setup.py b/test/10_cpp_standards/setup.py index 969ca39b..f848d0b1 100644 --- a/test/10_cpp_standards/setup.py +++ b/test/10_cpp_standards/setup.py @@ -1,7 +1,11 @@ -import os, sys -from setuptools import setup, Extension +import os import platform +from setuptools import ( + Extension, + setup, +) + standard = os.environ["STANDARD"] language_standard = "/std:c++" + standard if platform.system() == "Windows" else "-std=c++" + standard diff --git a/unit_test/main_util_fixtures.py b/unit_test/main_tests/conftest.py similarity index 95% rename from unit_test/main_util_fixtures.py rename to unit_test/main_tests/conftest.py index 21a7f36a..227b8df7 100644 --- a/unit_test/main_util_fixtures.py +++ b/unit_test/main_tests/conftest.py @@ -1,10 +1,15 @@ -import pytest - -import sys import os import subprocess +import sys -from cibuildwheel import linux, macos, windows, util +import pytest + +from cibuildwheel import ( + linux, + macos, + util, + windows, +) class ArgsInterceptor: @@ -15,6 +20,7 @@ class ArgsInterceptor: MOCK_PROJECT_DIR = 'some_project_dir' + @pytest.fixture(autouse=True) def mock_protection(monkeypatch): ''' @@ -31,13 +37,14 @@ def mock_protection(monkeypatch): monkeypatch.setattr(linux, 'build', fail_on_call) monkeypatch.setattr(macos, 'build', fail_on_call) + @pytest.fixture(autouse=True) def fake_project_dir(monkeypatch): ''' Monkey-patch enough for the main() function to run ''' - real_os_path_exists = os.path.exists + def mock_os_path_exists(path): if path == os.path.join(MOCK_PROJECT_DIR, 'setup.py'): return True diff --git a/unit_test/main_options_test.py b/unit_test/main_tests/main_options_test.py similarity index 98% rename from unit_test/main_options_test.py rename to unit_test/main_tests/main_options_test.py index 44d92da8..05a20afc 100644 --- a/unit_test/main_options_test.py +++ b/unit_test/main_tests/main_options_test.py @@ -1,14 +1,11 @@ -import pytest - import sys +import pytest + from cibuildwheel.__main__ import main from cibuildwheel.environment import ParsedEnvironment from cibuildwheel.util import BuildSelector -from main_util_fixtures import mock_protection, fake_project_dir, platform, intercepted_build_args - - # CIBW_PLATFORM is tested in main_platform_test.py @@ -93,6 +90,7 @@ def get_default_repair_command(platform): else: raise ValueError('Unknown platform', platform) + @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): @@ -225,5 +223,3 @@ def test_build_selector_migrations(intercepted_build_args, monkeypatch, option_n assert intercepted_build_selector.build_patterns == build_selector_patterns else: assert intercepted_build_selector.skip_patterns == build_selector_patterns - - diff --git a/unit_test/main_platform_test.py b/unit_test/main_tests/main_platform_test.py similarity index 93% rename from unit_test/main_platform_test.py rename to unit_test/main_tests/main_platform_test.py index 3de3be29..dae0c596 100644 --- a/unit_test/main_platform_test.py +++ b/unit_test/main_tests/main_platform_test.py @@ -1,10 +1,10 @@ -import pytest - import sys +import pytest + from cibuildwheel.__main__ import main -from main_util_fixtures import MOCK_PROJECT_DIR, mock_protection, fake_project_dir, platform, intercepted_build_args +from conftest import MOCK_PROJECT_DIR # noqa: I100 def test_unknown_platform_non_ci(monkeypatch, capsys):