diff --git a/unit_test/conftest.py b/unit_test/conftest.py index cbfdbb72..3d98c30b 100644 --- a/unit_test/conftest.py +++ b/unit_test/conftest.py @@ -12,7 +12,7 @@ def pytest_addoption(parser): @pytest.fixture -def fake_package_dir(monkeypatch): +def fake_package_dir(tmp_path, monkeypatch): """ Monkey-patch enough for the main() function to run """ @@ -25,6 +25,8 @@ def fake_package_dir(monkeypatch): return real_path_exists(path) args = ["cibuildwheel", str(MOCK_PACKAGE_DIR)] + tmp_path.joinpath(MOCK_PACKAGE_DIR).mkdir() monkeypatch.setattr(Path, "exists", mock_path_exists) monkeypatch.setattr(sys, "argv", args) + monkeypatch.chdir(tmp_path) return args diff --git a/unit_test/option_prepare_test.py b/unit_test/option_prepare_test.py index 10bca432..3eef68a7 100644 --- a/unit_test/option_prepare_test.py +++ b/unit_test/option_prepare_test.py @@ -44,7 +44,7 @@ def mock_build_container(monkeypatch): def test_build_default_launches(mock_build_container, fake_package_dir, monkeypatch): - monkeypatch.setattr(sys, "argv", ["cibuildwheel", "--platform=linux"]) + monkeypatch.setattr(sys, "argv", sys.argv + ["--platform=linux"]) main()