From 04c1a2aee5b1ae852a47e3cf2c56c1063be334de Mon Sep 17 00:00:00 2001 From: mayeut Date: Mon, 25 May 2020 14:55:04 +0200 Subject: [PATCH] Add test case for proper build isolation If there's not a proper build isolation then, the wheel for `cp27mu` will pick up the `spam.so` built for `cp27m` resulting in an import error. --- test/test_unicode.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 test/test_unicode.py diff --git a/test/test_unicode.py b/test/test_unicode.py new file mode 100644 index 00000000..85701573 --- /dev/null +++ b/test/test_unicode.py @@ -0,0 +1,31 @@ +import textwrap + +import pytest + +from . import utils +from . import test_projects + +project_with_unicode = test_projects.new_c_project( + spam_c_function_add=textwrap.dedent(r''' + { + Py_XDECREF(PyUnicode_FromStringAndSize("foo", 4)); + } + '''), +) + + +def test(tmp_path): + if utils.platform != 'linux': + pytest.skip('the docker test is only relevant to the linux build') + + project_dir = tmp_path / 'project' + project_with_unicode.generate(project_dir) + + # build the wheels + actual_wheels = utils.cibuildwheel_run(project_dir, add_env={ + 'CIBW_TEST_COMMAND': 'python -c "import spam"' + }) + + # check that the expected wheels are produced + expected_wheels = utils.expected_wheels('spam', '0.1.0') + assert set(actual_wheels) == set(expected_wheels)