From 81f960b17e0b4131f7ce2936df357909fa0f748d Mon Sep 17 00:00:00 2001 From: Joe Rickerby Date: Sun, 17 May 2020 16:54:33 +0100 Subject: [PATCH] Rename TemplateProject -> TestProject & tidy some comments --- test/template_projects/__init__.py | 2 -- test/test_0_basic.py | 4 +-- test/test_before_build.py | 4 +-- test/test_before_test.py | 4 +-- test/test_build_skip.py | 4 +-- test/test_cpp_standards.py | 25 +++++++++---------- test/test_dependency_versions.py | 4 +-- test/test_docker_images.py | 4 +-- test/test_environment.py | 6 ++--- test/test_manylinuxXXXX_only.py | 4 +-- test/test_projects/__init__.py | 2 ++ .../__main__.py | 4 +-- .../base.py | 10 ++++++-- .../{template_projects => test_projects}/c.py | 4 +-- test/test_ssl.py | 4 +-- test/test_subdir_package.py | 6 ++--- test/test_testing.py | 4 +-- 17 files changed, 50 insertions(+), 45 deletions(-) delete mode 100644 test/template_projects/__init__.py create mode 100644 test/test_projects/__init__.py rename test/{template_projects => test_projects}/__main__.py (88%) rename test/{template_projects => test_projects}/base.py (76%) rename test/{template_projects => test_projects}/c.py (97%) diff --git a/test/template_projects/__init__.py b/test/template_projects/__init__.py deleted file mode 100644 index ba6c61b6..00000000 --- a/test/template_projects/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -from .base import TemplateProject # noqa -from .c import new_c_project # noqa diff --git a/test/test_0_basic.py b/test/test_0_basic.py index 0bd6817d..60b309ab 100644 --- a/test/test_0_basic.py +++ b/test/test_0_basic.py @@ -1,9 +1,9 @@ import textwrap import platform -from . import template_projects +from . import test_projects from . import utils -basic_project = template_projects.new_c_project( +basic_project = test_projects.new_c_project( setup_py_add=textwrap.dedent(''' import os diff --git a/test/test_before_build.py b/test/test_before_build.py index 0ce92110..11c752f0 100644 --- a/test/test_before_build.py +++ b/test/test_before_build.py @@ -1,9 +1,9 @@ import textwrap from . import utils -from . import template_projects +from . import test_projects -project_with_before_build_asserts = template_projects.new_c_project( +project_with_before_build_asserts = test_projects.new_c_project( setup_py_add=textwrap.dedent(r''' import sys, os diff --git a/test/test_before_test.py b/test/test_before_test.py index 0ea3e5e0..d0dad59d 100644 --- a/test/test_before_test.py +++ b/test/test_before_test.py @@ -1,7 +1,7 @@ -from . import template_projects +from . import test_projects from . import utils -before_test_project = template_projects.new_c_project() +before_test_project = test_projects.new_c_project() before_test_project.files['test/spam_test.py'] = r''' import sys import os diff --git a/test/test_build_skip.py b/test/test_build_skip.py index ad91c8d4..11d125f6 100644 --- a/test/test_build_skip.py +++ b/test/test_build_skip.py @@ -1,9 +1,9 @@ import textwrap from . import utils -from . import template_projects +from . import test_projects -project_with_skip_asserts = template_projects.new_c_project( +project_with_skip_asserts = test_projects.new_c_project( setup_py_add=textwrap.dedent(r''' # explode if run on Python 2.7 or Python 3.7 (these should be skipped) if sys.version_info[0:2] == (2, 7): diff --git a/test/test_cpp_standards.py b/test/test_cpp_standards.py index 7dbca41a..0ecf196d 100644 --- a/test/test_cpp_standards.py +++ b/test/test_cpp_standards.py @@ -4,11 +4,11 @@ import jinja2 import pytest from . import utils -from .template_projects import TemplateProject +from .test_projects import TestProject -cpp_template_project = TemplateProject() +cpp_test_project = TestProject() -cpp_template_project.files['setup.py'] = jinja2.Template(r''' +cpp_test_project.files['setup.py'] = jinja2.Template(r''' from setuptools import Extension, setup setup( @@ -18,7 +18,7 @@ setup( ) ''') -cpp_template_project.files['spam.cpp'] = jinja2.Template(r''' +cpp_test_project.files['spam.cpp'] = jinja2.Template(r''' #include {{ spam_cpp_top_level_add }} @@ -72,7 +72,7 @@ MOD_INIT(spam) ''') -cpp11_project = cpp_template_project.copy() +cpp11_project = cpp_test_project.copy() cpp11_project.template_context['extra_compile_args'] = ( ['/std:c++11'] if utils.platform == 'windows' else ['-std=c++11'] ) @@ -95,7 +95,7 @@ def test_cpp11(tmp_path): assert set(actual_wheels) == set(expected_wheels) -cpp14_project = cpp_template_project.copy() +cpp14_project = cpp_test_project.copy() cpp14_project.template_context['extra_compile_args'] = ( ['/std:c++14'] if utils.platform == 'windows' else ['-std=c++14'] ) @@ -120,7 +120,10 @@ def test_cpp14(tmp_path): assert set(actual_wheels) == set(expected_wheels) -cpp17_project = cpp_template_project.copy() +cpp17_project = cpp_test_project.copy() + +# Python and PyPy 2.7 headers use the `register` keyword, which is forbidden in +# the C++17 standard, so we need the -Wno-register or /wd5033 options cpp17_project.template_context['extra_compile_args'] = ( ['/std:c++17', '/wd5033'] if utils.platform == 'windows' else ['-std=c++17', '-Wno-register'] ) @@ -136,15 +139,11 @@ def test_cpp17(tmp_path): cpp17_project.generate(project_dir) - # - Python and PyPy 2.7 use the `register` keyword which is forbidden in - # the C++17 standard - # - The manylinux1 docker image does not have a compiler which supports - # C++11 - # - Pypy's distutils sets the default compiler to 'msvc9compiler', which - # is too old to support cpp17. if os.environ.get('APPVEYOR_BUILD_WORKER_IMAGE', '') == 'Visual Studio 2015': pytest.skip('Visual Studio 2015 does not support C++17') + # Pypy's distutils sets the default compiler to 'msvc9compiler', which + # is too old to support cpp17. add_env = {'CIBW_SKIP': 'cp27-win* pp??-*'} if utils.platform == 'macos': diff --git a/test/test_dependency_versions.py b/test/test_dependency_versions.py index 87a849c7..e6645dec 100644 --- a/test/test_dependency_versions.py +++ b/test/test_dependency_versions.py @@ -5,10 +5,10 @@ import textwrap import cibuildwheel.util from . import utils -from . import template_projects +from . import test_projects -project_with_expected_version_checks = template_projects.new_c_project( +project_with_expected_version_checks = test_projects.new_c_project( setup_py_add=textwrap.dedent(r''' import subprocess import os diff --git a/test/test_docker_images.py b/test/test_docker_images.py index be5ceaa8..f101c4fd 100644 --- a/test/test_docker_images.py +++ b/test/test_docker_images.py @@ -4,9 +4,9 @@ import textwrap import pytest from . import utils -from . import template_projects +from . import test_projects -dockcross_only_project = template_projects.new_c_project( +dockcross_only_project = test_projects.new_c_project( setup_py_add=textwrap.dedent(r''' import os, sys diff --git a/test/test_environment.py b/test/test_environment.py index d310e991..470a151f 100644 --- a/test/test_environment.py +++ b/test/test_environment.py @@ -3,10 +3,10 @@ import pytest import subprocess import textwrap from . import utils -from . import template_projects +from . import test_projects -project_with_environment_asserts = template_projects.new_c_project( +project_with_environment_asserts = test_projects.new_c_project( setup_py_add=textwrap.dedent(r''' import os @@ -48,7 +48,7 @@ def test_overridden_path(tmp_path): project_dir = tmp_path / 'project' output_dir = tmp_path / 'output' - project = template_projects.new_c_project() + project = test_projects.new_c_project() project.generate(project_dir) output_dir.mkdir() diff --git a/test/test_manylinuxXXXX_only.py b/test/test_manylinuxXXXX_only.py index e159cbae..68160688 100644 --- a/test/test_manylinuxXXXX_only.py +++ b/test/test_manylinuxXXXX_only.py @@ -4,10 +4,10 @@ import textwrap import pytest from . import utils -from . import template_projects +from . import test_projects # TODO: specify these at runtime according to manylinux_image -project_with_manylinux_symbols = template_projects.new_c_project( +project_with_manylinux_symbols = test_projects.new_c_project( spam_c_top_level_add=textwrap.dedent(r''' #include diff --git a/test/test_projects/__init__.py b/test/test_projects/__init__.py new file mode 100644 index 00000000..48d7dbec --- /dev/null +++ b/test/test_projects/__init__.py @@ -0,0 +1,2 @@ +from .base import TestProject # noqa +from .c import new_c_project # noqa diff --git a/test/template_projects/__main__.py b/test/test_projects/__main__.py similarity index 88% rename from test/template_projects/__main__.py rename to test/test_projects/__main__.py index 87771528..af5b14dc 100644 --- a/test/template_projects/__main__.py +++ b/test/test_projects/__main__.py @@ -7,8 +7,8 @@ import subprocess def main(): parser = ArgumentParser( - prog="python -m test.template_projects", - description='Generate a template project to check it out' + prog="python -m test.test_projects", + description='Generate a test project to check it out' ) parser.add_argument('PROJECT', help=''' Python path to a project object. E.g. test.test_0_basic.basic_project diff --git a/test/template_projects/base.py b/test/test_projects/base.py similarity index 76% rename from test/template_projects/base.py rename to test/test_projects/base.py index 2ea1bc69..5cac80ad 100644 --- a/test/template_projects/base.py +++ b/test/test_projects/base.py @@ -7,7 +7,13 @@ FilesDict = Dict[str, Union[str, jinja2.Template]] TemplateContext = Dict[str, Any] -class TemplateProject: +class TestProject: + ''' + An object that represents a project that can be built by cibuildwheel. + Can be manipulated in tests by changing `files` and `template_context`. + + Write out to the filesystem using `generate`. + ''' files: FilesDict template_context: TemplateContext @@ -27,7 +33,7 @@ class TemplateProject: f.write(content) def copy(self): - other = TemplateProject() + other = TestProject() other.files = self.files.copy() other.template_context = self.template_context.copy() return other diff --git a/test/template_projects/c.py b/test/test_projects/c.py similarity index 97% rename from test/template_projects/c.py rename to test/test_projects/c.py index ef64745f..6f06c1ba 100644 --- a/test/template_projects/c.py +++ b/test/test_projects/c.py @@ -1,5 +1,5 @@ import jinja2 -from .base import TemplateProject +from .base import TestProject SPAM_C_TEMPLATE = r''' @@ -81,7 +81,7 @@ version = 0.1.0 def new_c_project(*, spam_c_top_level_add='', spam_c_function_add='', setup_py_add='', setup_py_setup_args_add='', setup_cfg_add=''): - project = TemplateProject() + project = TestProject() project.files.update({ 'spam.c': jinja2.Template(SPAM_C_TEMPLATE), diff --git a/test/test_ssl.py b/test/test_ssl.py index 13c81b24..4ade9bb8 100644 --- a/test/test_ssl.py +++ b/test/test_ssl.py @@ -1,9 +1,9 @@ import textwrap from . import utils -from . import template_projects +from . import test_projects -project_with_ssl_tests = template_projects.new_c_project( +project_with_ssl_tests = test_projects.new_c_project( setup_py_add=textwrap.dedent(r''' import ssl import sys diff --git a/test/test_subdir_package.py b/test/test_subdir_package.py index ab52c274..53bd9520 100644 --- a/test/test_subdir_package.py +++ b/test/test_subdir_package.py @@ -3,10 +3,10 @@ import os import jinja2 from . import utils -from .template_projects import TemplateProject -from .template_projects.c import SPAM_C_TEMPLATE +from .test_projects import TestProject +from .test_projects.c import SPAM_C_TEMPLATE -subdir_package_project = TemplateProject() +subdir_package_project = TestProject() subdir_package_project.files['src/spam/spam.c'] = jinja2.Template(SPAM_C_TEMPLATE) subdir_package_project.template_context['spam_c_top_level_add'] = '' diff --git a/test/test_testing.py b/test/test_testing.py index 8c5a92d2..dda833ea 100644 --- a/test/test_testing.py +++ b/test/test_testing.py @@ -5,9 +5,9 @@ import textwrap import pytest from . import utils -from . import template_projects +from . import test_projects -project_with_a_test = template_projects.new_c_project( +project_with_a_test = test_projects.new_c_project( setup_cfg_add=textwrap.dedent(r''' [options.extras_require] test = nose