2021-10-12 02:05:47 +01:00
|
|
|
import sys
|
|
|
|
|
from pathlib import Path
|
|
|
|
|
|
2020-06-26 21:37:02 +01:00
|
|
|
import pytest
|
|
|
|
|
|
2021-10-12 02:05:47 +01:00
|
|
|
MOCK_PACKAGE_DIR = Path("some_package_dir")
|
|
|
|
|
|
2020-06-26 21:37:02 +01:00
|
|
|
|
|
|
|
|
def pytest_addoption(parser):
|
2021-04-30 17:56:34 -04:00
|
|
|
parser.addoption("--run-docker", action="store_true", default=False, help="run docker tests")
|
2022-06-27 16:45:27 +01:00
|
|
|
parser.addoption("--run-podman", action="store_true", default=False, help="run podman tests")
|
2022-09-25 10:42:19 +02:00
|
|
|
parser.addoption(
|
|
|
|
|
"--run-cp38-universal2",
|
|
|
|
|
action="store_true",
|
|
|
|
|
default=False,
|
|
|
|
|
help="macOS cp38 uses the universal2 installer",
|
|
|
|
|
)
|
2022-09-25 10:41:01 +00:00
|
|
|
|
2021-10-12 02:05:47 +01:00
|
|
|
|
2024-08-21 00:34:31 -04:00
|
|
|
@pytest.fixture
|
2022-07-14 15:23:59 +02:00
|
|
|
def fake_package_dir(tmp_path, monkeypatch):
|
2021-10-12 02:05:47 +01:00
|
|
|
"""
|
|
|
|
|
Monkey-patch enough for the main() function to run
|
|
|
|
|
"""
|
|
|
|
|
real_path_exists = Path.exists
|
|
|
|
|
|
|
|
|
|
def mock_path_exists(path):
|
2022-04-26 22:21:27 -04:00
|
|
|
if str(path).endswith(str(MOCK_PACKAGE_DIR / "setup.py")):
|
2021-10-12 02:05:47 +01:00
|
|
|
return True
|
|
|
|
|
else:
|
|
|
|
|
return real_path_exists(path)
|
|
|
|
|
|
|
|
|
|
args = ["cibuildwheel", str(MOCK_PACKAGE_DIR)]
|
2022-07-14 15:23:59 +02:00
|
|
|
tmp_path.joinpath(MOCK_PACKAGE_DIR).mkdir()
|
2021-10-12 02:05:47 +01:00
|
|
|
monkeypatch.setattr(Path, "exists", mock_path_exists)
|
|
|
|
|
monkeypatch.setattr(sys, "argv", args)
|
2022-07-14 15:23:59 +02:00
|
|
|
monkeypatch.chdir(tmp_path)
|
2021-10-12 02:05:47 +01:00
|
|
|
return args
|