Files

33 lines
998 B
Python
Raw Permalink 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
2026-04-01 10:23:02 -04:00
def pytest_addoption(parser: pytest.Parser) -> None:
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")
2021-10-12 02:05:47 +01:00
@pytest.fixture
2026-04-01 10:23:02 -04:00
def fake_package_dir(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> list[str]:
2021-10-12 02:05:47 +01:00
"""
Monkey-patch enough for the main() function to run
"""
real_path_exists = Path.exists
2026-04-01 10:23:02 -04:00
def mock_path_exists(path: Path) -> bool:
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