Refactor to use tmp_path and pathlib paths

This commit is contained in:
Joe Rickerby
2020-05-03 14:08:57 +01:00
parent 33f210b85c
commit dafe5cd1f7
12 changed files with 37 additions and 37 deletions
+4 -4
View File
@@ -13,8 +13,8 @@ basic_project = CTemplateProject(
)
def test(tmpdir):
project_dir = str(tmpdir)
def test(tmp_path):
project_dir = tmp_path / 'project'
basic_project.generate(project_dir)
# build the wheels
@@ -25,8 +25,8 @@ def test(tmpdir):
assert set(actual_wheels) == set(expected_wheels)
def test_build_identifiers(tmpdir):
project_dir = str(tmpdir)
def test_build_identifiers(tmp_path):
project_dir = tmp_path / 'project'
basic_project.generate(project_dir)
# check that the number of expected wheels matches the number of build
+2 -2
View File
@@ -28,8 +28,8 @@ project_with_before_build_asserts = CTemplateProject(
)
def test(tmpdir):
project_dir = str(tmpdir)
def test(tmp_path):
project_dir = tmp_path / 'project'
project_with_before_build_asserts.generate(project_dir)
# build the wheels
+2 -2
View File
@@ -34,8 +34,8 @@ class TestBeforeTest(TestCase):
'''
def test(tmpdir):
project_dir = str(tmpdir)
def test(tmp_path):
project_dir = tmp_path / 'project'
before_test_project.generate(project_dir)
# build the wheels
+2 -2
View File
@@ -14,8 +14,8 @@ project_with_skip_asserts = CTemplateProject(
)
def test(tmpdir):
project_dir = str(tmpdir)
def test(tmp_path):
project_dir = tmp_path / 'project'
project_with_skip_asserts.generate(project_dir)
# build the wheels
+6 -6
View File
@@ -73,9 +73,9 @@ MOD_INIT(spam)
''')
def test_cpp11(tmpdir):
def test_cpp11(tmp_path):
# This test checks that the C++11 standard is supported
project_dir = str(tmpdir)
project_dir = tmp_path / 'project'
project = cpp_template_project.copy()
extra_compile_args = ['/std:c++11'] if utils.platform == 'windows' else ['-std=c++11']
@@ -93,9 +93,9 @@ def test_cpp11(tmpdir):
assert set(actual_wheels) == set(expected_wheels)
def test_cpp14(tmpdir):
def test_cpp14(tmp_path):
# This test checks that the C++14 standard is supported
project_dir = str(tmpdir)
project_dir = tmp_path / 'project'
project = cpp_template_project.copy()
extra_compile_args = ['/std:c++14'] if utils.platform == 'windows' else ['-std=c++14']
@@ -117,9 +117,9 @@ def test_cpp14(tmpdir):
assert set(actual_wheels) == set(expected_wheels)
def test_cpp17(tmpdir):
def test_cpp17(tmp_path):
# This test checks that the C++17 standard is supported
project_dir = str(tmpdir)
project_dir = tmp_path / 'project'
project = cpp_template_project.copy()
if utils.platform == 'windows':
+3 -3
View File
@@ -51,11 +51,11 @@ def get_versions_from_constraint_file(constraint_file):
@pytest.mark.parametrize('python_version', ['2.7', '3.5', '3.8'])
def test_pinned_versions(tmpdir, python_version):
def test_pinned_versions(tmp_path, python_version):
if utils.platform == 'linux':
pytest.skip('linux doesn\'t pin individual tool versions, it pins manylinux images instead')
project_dir = str(tmpdir)
project_dir = tmp_path / 'project'
project_with_expected_version_checks.generate(project_dir)
build_environment = {}
@@ -108,7 +108,7 @@ def test_dependency_constraints_file(tmp_path, python_version):
if utils.platform == 'linux':
pytest.skip('linux doesn\'t pin individual tool versions, it pins manylinux images instead')
project_dir = str(tmp_path / 'project')
project_dir = tmp_path / 'project'
project_with_expected_version_checks.generate(project_dir)
tool_versions = {
+2 -2
View File
@@ -20,13 +20,13 @@ dockcross_only_project = CTemplateProject(
)
def test(tmpdir):
def test(tmp_path):
if utils.platform != 'linux':
pytest.skip('the test is only relevant to the linux build')
if platform.machine() not in ['x86_64', 'i686']:
pytest.skip('this test is currently only possible on x86_64/i686 due to availability of alternative images')
project_dir = str(tmpdir)
project_dir = tmp_path / 'project'
dockcross_only_project.generate(project_dir)
actual_wheels = utils.cibuildwheel_run(project_dir, add_env={
+4 -4
View File
@@ -27,8 +27,8 @@ project_with_environment_asserts = CTemplateProject(
)
def test(tmpdir):
project_dir = str(tmpdir)
def test(tmp_path):
project_dir = tmp_path / 'project'
project_with_environment_asserts.generate(project_dir)
# write some information into the CIBW_ENVIRONMENT, for expansion and
@@ -45,8 +45,8 @@ def test(tmpdir):
def test_overridden_path(tmp_path):
project_dir = str(tmp_path / 'project')
output_dir = str(tmp_path / 'output')
project_dir = tmp_path / 'project'
output_dir = tmp_path / 'output'
CTemplateProject().generate(project_dir)
# mess up PATH, somehow
+2 -2
View File
@@ -33,14 +33,14 @@ project_with_manylinux_symbols = CTemplateProject(
@pytest.mark.parametrize('manylinux_image', ['manylinux1', 'manylinux2010', 'manylinux2014'])
def test(manylinux_image, tmpdir):
def test(manylinux_image, tmp_path):
if utils.platform != 'linux':
pytest.skip('the docker test is only relevant to the linux build')
elif platform.machine() not in ['x86_64', 'i686']:
if manylinux_image in ['manylinux1', 'manylinux2010']:
pytest.skip("manylinux1 and 2010 doesn't exist for non-x86 architectures")
project_dir = str(tmpdir)
project_dir = tmp_path / 'project'
project_with_manylinux_symbols.generate(project_dir)
# build the wheels
+2 -2
View File
@@ -22,10 +22,10 @@ project_with_ssl_tests = CTemplateProject(
)
def test(tmpdir):
def test(tmp_path):
# this test checks that SSL is working in the build environment using
# some checks in setup.py.
project_dir = str(tmpdir)
project_dir = tmp_path / 'project'
project_with_ssl_tests.generate(project_dir)
utils.cibuildwheel_run(project_dir)
+2 -2
View File
@@ -26,8 +26,8 @@ print('before_build.py executed!')
'''
def test(capfd, tmpdir):
project_dir = str(tmpdir)
def test(capfd, tmp_path):
project_dir = tmp_path / 'project'
subdir_package_project.generate(project_dir)
package_dir = os.path.join(project_dir, 'src', 'spam')
+6 -6
View File
@@ -25,8 +25,8 @@ class TestSpam(TestCase):
'''
def test(tmpdir):
project_dir = str(tmpdir)
def test(tmp_path):
project_dir = tmp_path / 'project'
project_with_a_test.generate(project_dir)
# build and test the wheels
@@ -43,8 +43,8 @@ def test(tmpdir):
assert set(actual_wheels) == set(expected_wheels)
def test_extras_require(tmpdir):
project_dir = str(tmpdir)
def test_extras_require(tmp_path):
project_dir = tmp_path / 'project'
project_with_a_test.generate(project_dir)
# build and test the wheels
@@ -63,8 +63,8 @@ def test_extras_require(tmpdir):
def test_failing_test(tmp_path):
"""Ensure a failing test causes cibuildwheel to error out and exit"""
project_dir = str(tmp_path / 'project')
output_dir = str(tmp_path / 'output')
project_dir = tmp_path / 'project'
output_dir = tmp_path / 'output'
project_with_a_test.generate(project_dir)
with pytest.raises(subprocess.CalledProcessError):