Files
cibuildwheel/unit_test/conftest.py
T

39 lines
1.1 KiB
Python
Raw Normal View History

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")
parser.addoption("--run-podman", action="store_true", default=False, help="run podman tests")
parser.addoption(
"--run-cp38-universal2",
action="store_true",
default=False,
help="macOS cp38 uses the universal2 installer",
)
2021-10-12 02:05:47 +01:00
@pytest.fixture
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)]
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)
monkeypatch.chdir(tmp_path)
2021-10-12 02:05:47 +01:00
return args