chore: rework single python tests (#1835)
* chore: rework single python tests * chore(tests): limit number of builds in test_abi3 * chore(tests): limit number of builds in test_before_all * apply review suggestion use `os.path.samefile` rather than comparing `os.stat` directly.
This commit is contained in:
+21
-8
@@ -10,13 +10,22 @@ from . import test_projects, utils
|
||||
project_with_before_build_asserts = test_projects.new_c_project(
|
||||
setup_py_add=textwrap.dedent(
|
||||
r"""
|
||||
# assert that the Python version as written to text_info.txt in the CIBW_BEFORE_ALL step
|
||||
# is the same one as is currently running.
|
||||
import os
|
||||
|
||||
with open("text_info.txt") as f:
|
||||
stored_text = f.read()
|
||||
|
||||
print("## stored text: " + stored_text)
|
||||
assert stored_text == "sample text 123"
|
||||
|
||||
# assert that the Python version as written to python_prefix.txt in the CIBW_BEFORE_ALL step
|
||||
# is not the same one as is currently running.
|
||||
with open('python_prefix.txt') as f:
|
||||
stored_prefix = f.read()
|
||||
print('stored_prefix', stored_prefix)
|
||||
print('sys.prefix', sys.prefix)
|
||||
# Works around path-comparison bugs caused by short-paths on Windows e.g.
|
||||
# vssadm~1 instead of vssadministrator
|
||||
assert not os.path.samefile(stored_prefix, sys.prefix)
|
||||
"""
|
||||
)
|
||||
)
|
||||
@@ -30,21 +39,24 @@ def test(tmp_path):
|
||||
print("dummy text", file=ff)
|
||||
|
||||
# build the wheels
|
||||
before_all_command = '''python -c "import os;open('{project}/text_info.txt', 'w').write('sample text '+os.environ.get('TEST_VAL', ''))"'''
|
||||
before_all_command = (
|
||||
"""python -c "import os, sys;open('{project}/text_info.txt', 'w').write('sample text '+os.environ.get('TEST_VAL', ''))" && """
|
||||
'''python -c "import sys; open('{project}/python_prefix.txt', 'w').write(sys.prefix)"'''
|
||||
)
|
||||
actual_wheels = utils.cibuildwheel_run(
|
||||
project_dir,
|
||||
add_env={
|
||||
# write python version information to a temporary file, this is
|
||||
# checked in setup.py
|
||||
"CIBW_BEFORE_ALL": before_all_command,
|
||||
"CIBW_BEFORE_ALL_LINUX": f'{before_all_command} && python -c "import sys; assert sys.version_info >= (3, 6)"',
|
||||
"CIBW_BEFORE_ALL_LINUX": f'{before_all_command} && python -c "import sys; assert sys.version_info >= (3, 8)"',
|
||||
"CIBW_ENVIRONMENT": "TEST_VAL='123'",
|
||||
},
|
||||
single_python=True,
|
||||
)
|
||||
|
||||
# also check that we got the right wheels
|
||||
(project_dir / "text_info.txt").unlink()
|
||||
expected_wheels = utils.expected_wheels("spam", "0.1.0")
|
||||
expected_wheels = utils.expected_wheels("spam", "0.1.0", single_python=True)
|
||||
assert set(actual_wheels) == set(expected_wheels)
|
||||
|
||||
|
||||
@@ -72,7 +84,8 @@ def test_cwd(tmp_path):
|
||||
"CIBW_BEFORE_ALL": f'''python -c "import os; assert os.getcwd() == {str(project_dir)!r}"''',
|
||||
"CIBW_BEFORE_ALL_LINUX": '''python -c "import os; assert os.getcwd() == '/project'"''',
|
||||
},
|
||||
single_python=True,
|
||||
)
|
||||
|
||||
expected_wheels = utils.expected_wheels("spam", "0.1.0")
|
||||
expected_wheels = utils.expected_wheels("spam", "0.1.0", single_python=True)
|
||||
assert set(actual_wheels) == set(expected_wheels)
|
||||
|
||||
Reference in New Issue
Block a user