Skip to content

Commit 09c3109

Browse files
authored
Use pytest features to avoid having to use mv (#1022)
This updates the `test-command` parameter for cibuildwheel to include the argument `--import-mode=importlib` to pytest. This argument directs pytest not to add the project root to `sys.path` in a way that would cause the local `qsimcirq` source directory to shadow the installed wheel. This makes the manual moving of the directory unnecessary.
1 parent d225b29 commit 09c3109

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

pyproject.toml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,9 @@ build = "cp310-* cp311-* cp312-* cp313-* cp314-*"
128128
dependency-versions = "latest"
129129
enable = ["cpython-prerelease"]
130130
environment.PIP_PREFER_BINARY = "1"
131-
# Due to package & module name conflict, temporarily move it away to run tests:
132-
before-test = "pip install --group dev && mv {package}/qsimcirq /tmp"
133-
test-command = """
134-
pytest -n auto -s -v {package}/qsimcirq_tests/qsimcirq_test.py &&
135-
mv /tmp/qsimcirq {package}
136-
"""
131+
before-test = "pip install --group dev"
132+
# import-mode=importlib prevents local source shadowing when importing qsimcirq.
133+
test-command = "pytest --import-mode=importlib -n auto -s -v {package}/qsimcirq_tests/qsimcirq_test.py"
137134

138135
[[tool.cibuildwheel.overrides]]
139136
# Help increase the chances that pip will find binary wheels for NumPy.

0 commit comments

Comments
 (0)